如何在 matplotlib 中制作水平误差线而不是垂直误差线

How to make horizontal error bars instead of vertical in matplotlib

我已经通过 matplotlib 创建了错误栏,但是,我希望它们是水平的而不是垂直的。

ax.errorbar(x, y, deviation, fmt='bo')

尝试提供 xerr 属性 matplotlib.pyplot.errorbar(x, y, xerr)

xerr:定义水平误差条尺寸。

xerr, yerr : float or array-like, shape(N,) or shape(2, N), optional

误差条尺寸:

  • 标量:所有数据点的对称 +/- 值。
  • shape(N,):每个数据点的对称 +/- 值。
  • shape(2, N):每个条形的独立 - 和 + 值。第一行包含
  • 较低的错误,第二行包含较高的错误。
  • None: 没有错误栏。