Python/matplotlib 在直方图中显示置信度
这是我的问题。我收集了一些数据以获得“数字化”pdf,这很好。 现在,我想找到一种通过对 bin 组进行不同着色来指示不同置信区间的方法。 特别是,从包含我想要找到的最高计数的垃圾箱开始,并将面积总和小于 0.6 的所有最高垃圾箱涂上颜色(例如红色)。然后,总是通过减少计数来挑选新的垃圾箱,我想将红色区域增加到 0.8 的垃圾箱涂成橙色。 我正在考虑使用 numpy 来获取垃圾箱和计数,将它们分为 3 个系列(红色、橙色和原始颜色),并使用 pyplot 的条形图绘制它们。 希望您能指出更快的方法,谢谢!
here is my problem. I have some data I binned to obtain a "digitalised" pdf, and that's fine.
Now, I wanted to find a way to indicate different confidence intervals by coloring the bin groups differently.
In particular, starting with the bin containing the highest count I wanted to find and colour, say red, all the highest bins whose area sum to less than say .6. Then, always picking new bins by decreasing counts, i want to colour the bins who increase my red area to .8 in orange.
I was considering using numpy to get bins and counts, sort them into 3 series (red, orange and original colour) and plot them with pyplot's bar.
Hope you can point out a faster way, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解你的问题,我认为下面的代码将完成你的建议。这似乎与您考虑的方法有点不同,我不确定它是否更有效。无论如何,了解别人做某事的方式通常会有所帮助。它假设已经生成了一个 pdf(直方图),其中的 bin 由变量“bins”表示,bin 宽度由变量“binwidth”表示。
If I understand your question correctly, I think the code below will do what you are suggesting. It seems a little different than the approach you were considering, and I'm not sure it is more efficient. Regardless, it usually helps to see the way someone else would do something. It assumes an already generated pdf (histogram) with a bins represented by the varialble "bins" and bin width represented by the variable "binwidth".