7
我需要绘制条形图不对称误差棒...matplotlib酒吧不对称误差条
的matplotlib.pyplot.bar函数的文档说:
Detail: xerr and yerr are passed directly to errorbar(), so they can also have shape 2xN for independent specification of lower and upper errors.
但是,我可以不给一个2×N个排列到yerr ...
import numpy as np
import matplotlib.pyplot as plt
plt.bar(xrange(5), [2,5,3,4,7], yerr=[[1,4,2,3,6],[4,10,6,8,14]]) #DO NOT work!
并告诉我下面的错误:
Traceback (most recent call last):
File "bar_stacked.py", line 9, in <module>
plt.bar(xrange(5), [2,5,3,4,7], yerr=[[1,4,2,3,6],[4,10,6,8,14]])
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 1742, in bar
ret = ax.bar(left, height, width, bottom, color, edgecolor, linewidth, yerr, xerr, ecolor, capsize, align, orientation, log, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 4253, in bar
"incompatible sizes: bar() argument 'yerr' must be len(%s) or scalar" % nbars)
ValueError: incompatible sizes: bar() argument 'yerr' must be len(5) or scalar
但是,不是此函数:
import numpy as np
import matplotlib.pyplot as plt
plt.errorbar(xrange(5), [2,5,3,4,7], yerr=[[1,4,2,3,6],[4,10,6,8,14]])
工作正常。
matplotlib.pyplot.bar不再支持yerr的2xN数组吗? 如果答案是肯定的......我如何绘制一个带有不对称误差线的条形图?
谢谢你的时间!
我有0.99.3版本...我gona编译1.1.1,非常感谢! – Geparada
已解决!谢谢。 – Geparada