我有一个时间序列的数据,我有数量y和它的误差yerr。我现在想创建一个图,显示y对相位(即时间/周期% 1)的垂直误差条(yerr)。为此,我通常使用pyplot.errorbar(time,y,yerr=yerr,...)
但是,我想使用一个颜色条/Map来指示同一图中的时间值。
我这样做是为了:
pylab.errorbar( phase, y, yerr=err, fmt=None, marker=None, mew=0 )
pylab.scatter( phase, y, c=time, cmap=cm )
不幸的是,这将绘制单色误差条(默认为蓝色)。由于我每个图有~1600个点,这使得散点图的色图消失在误差条后面。下面的图片显示了我的意思:
有没有一种方法可以使用与散点图中使用的颜色Map表相同的颜色Map表来绘制误差条?我不想调用errorbar 1600次...
4条答案
按热度按时间oipij1gg1#
除了改变颜色之外,另一个建议是改变误差条与散点图的
zorder
,这将用户的注意力集中在数据上,并绘制出误差的大致形状(我认为这是您的意图)。qoefvg9y2#
我找了一段时间的解决方案,终于找到了一条路:
yquaqz183#
很抱歉把这个挖回来,但只是遇到类似的东西我自己,这是我的解决方案的基础上以前的React。
这会将标记、错误条和大写字母设置为色彩Map表中的相同颜色:
**编辑:**在更改为matplotlib v3.1.1后,上述功能停止工作,但这里有一个解决方案:
最后,为了完整性,这里有一个它应该产生的图:
6tdlim6h4#
您可以在
pylab.errorbar
中使用ecolor
可选参数,就像在pylab.scatter
中使用color
参数一样: