累积直方图的最后一点在y = 0 [英] cumulative histogram has last point at y=0

查看:55
本文介绍了累积直方图的最后一点在y = 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建直方图

pylab.hist(data,weights,histtype='step',normed=False,bins=150,cumulative=True)

获取紫罗兰色的线(还有其他图解,现在已经不相关了)

getting (there are other plots, which are irrelevant now) the violet line

为什么直方图最后又降为零?累积功能通常不应减少.有没有办法解决这个问题,是错误还是功能?

Why is the histogram dropping to zero at the end again? Cumulative functions should be in general non-decreasing. Is there a way to work around this, be it bug or feature?

解决方案(破解):

# histtype=step returns a single patch, open polygon
n,bins,patches=pylab.hist(data,weights,histtype='step',cumulative=True)
# just delete the last point
patches[0].set_xy(patches[0].get_xy()[:-1])

推荐答案

这是默认行为.可以将其视为直方图的轮廓,如条形图.至于一个快速的解决方法,我不知道.一种解决方案是自己计算直方图: python直方图单线

This is default behaviour. Think of it as an outline of the histogram as a bar chart. As for a quick workaround, not that I am aware of. A solution would be to calculate the histogram on your own: python histogram one-liner

这篇关于累积直方图的最后一点在y = 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆