Python 数据覆盖的Matplotlib errorbar行

Python 数据覆盖的Matplotlib errorbar行,python,matplotlib,Python,Matplotlib,我在这里用matplotlib绘制了两个数据集,其中一个红色表示典型错误。但是,这些线绘制在另一个拥挤集的数据点下方,因此被隐藏。有没有办法强迫errorbar行位于顶部 以下是我所拥有的: fig, ax = plt.subplots(1,1) ax.plot(xdata, ydata, 'ko', markersize=0.5) ax.errorbar([0]*len(err_yvals), err_yvals, xerr=xerrors, yerr=yerrors,

我在这里用matplotlib绘制了两个数据集,其中一个红色表示典型错误。但是,这些线绘制在另一个拥挤集的数据点下方,因此被隐藏。有没有办法强迫errorbar行位于顶部

以下是我所拥有的:

fig, ax = plt.subplots(1,1)

ax.plot(xdata, ydata, 'ko', markersize=0.5)
ax.errorbar([0]*len(err_yvals), err_yvals, xerr=xerrors, yerr=yerrors, 
             fmt='o', c='red', ms=3, elinewidth=1)
fig.tight_layout()

我希望红色的错误条点始终位于顶部:

下面是一个带有一些模拟数据的示例:

fig, ax = plt.subplots(1,1)

data = np.random.rand(10000, 2)
xdata, ydata = data[:,0], data[:,1]

err_yvals = [0.5]* 3
xerrors = 0.3
yerrors = 0.3

ax.plot(xdata, ydata, 'ko', markersize=2)
ax.errorbar([0.5]*len(err_yvals), err_yvals, xerr=xerrors, yerr=yerrors, 
             fmt='o', c='red', ms=10, elinewidth=2, zorder=3)
fig.tight_layout()
使用zorder=3参数,误差条绘制在点的顶部

尝试将zorder=3参数添加到对errorbar的调用中。请看这里: