我有一些数据y是用非对称误差条yerr (=[up, down])绘制的。数据y在末尾包含一些np.nan值,对于yerr也是如此。然而,当我使用matplotlib的errorbar函数绘制数据时,它得到了这种奇怪的标记行为:

是什么导致了这种情况?我运行了几次检查,nan值排成一行,这意味着根本不应该绘制它们!
下面是函数:
axis.errorbar(profile.R, profile.M, yerr=profile.MW, fmt='b.')
axis.set_ylim(axis.get_ylim()[::-1])
这是一些图片:在重新短语:axis.errorbar(profile.R, profile.M, yerr=(profile.MW[0], profile.MW[1]), fmt='b.')之后,它仍然在重新短语:axis.errorbar(profile.R, profile.M, yerr=(profile.MW[1], profile.MW[1]), fmt='b.')之后产生相同的情节

我也降级了matplotlib,但它仍然不能工作!
但是当我手动从最后8个元素的np.arrays中取出值时(axis.errorbar([32.9592, 34.60716, 36.33696, 38.15418, 40.06254, 42.06576, 44.16756, 46.37724],[np.nan, 28.18328608, 27.41428602, np.nan, 27.30407038, np.nan, np.nan, np.nan], yerr=[[np.nan, 1.16532339, 0.73753135, np.nan, 0.68722997, np.nan, np.nan, np.nan], [np.nan, 1.16532339, 0.73753135, np.nan, 0.68722997, np.nan, np.nan, np.nan]]))

它成功了!!见鬼!
有什么想法吗?
谢谢
发布于 2014-01-03 05:19:03
不应该是的。向我们展示一些您的数据和代码。版本相关?我不这么认为,我在matplotlib 1.3.1上
>>> import matplotlib.pyplot as plt
>>> from numpy import *
>>> x=arange(10)*1.
>>> y=random.randint(0,20,size=10)*1.
>>> plt.plot(x, y, 'o-')
>>> y[6]=np.nan
>>> y[8]=np.nan
>>> e=random.random(size=10)
>>> e[6]=np.nan
>>> e[8]=np.nan
>>> e1=random.random(size=10)
>>> e1[8]=np.nan
>>> e1[6]=np.nan
>>> e0=vstack((e,e1))
>>> plt.errorbar(x,y,yerr=e)
<Container object of 3 artists>
>>> x
array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
>>> y
array([ 12., 7., 2., 4., 16., 4., nan, 5., nan, 14.])
>>> e
array([ 0.55292182, 0.18636933, 0.4564491 , 0.74029 , 0.54939223,
0.98015167, nan, 0.08164338, nan, 0.1865567 ])
>>> e1
array([ 0.31619386, 0.06603335, 0.63795806, 0.70372424, 0.8639665 ,
0.01439499, nan, 0.73742553, nan, 0.06838048])

https://stackoverflow.com/questions/20885913
复制相似问题