【问题标题】:pyqtgraph ErrorBarItem doesn't draw a vertical line connecting horizontal error barspyqtgraph ErrorBarItem 不绘制连接水平误差线的垂直线
【发布时间】:2021-03-07 02:36:43
【问题描述】:

考虑以下代码:

import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np

pg.setConfigOptions(antialias=True)

yPoints = np.array([4.2315e-12, 5.0400e-12, 4.7119e-12, 5.0892e-12,])
xPoints = np.array([1, 2, 3, 4])
errors = np.array([2.9131e-13, 3.452e-13, 3.3071e-13, 3.762e-13 + 3e-13])

plt = pg.plot()
errorBarItem = pg.ErrorBarItem(x=xPoints, y=yPoints,  top=errors, bottom=errors, beam=0.2)
plt.addItem(errorBarItem)
plt.plot(xPoints, yPoints, symbol='o', pen={'color': 0.8, 'width': 2})

## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
  import sys
  if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
    QtGui.QApplication.instance().exec_()

哪些情节:

连接水平误差线的垂直线似乎没有画在一定范围以下(?)。

有没有办法强制 ErrorBarItem 总是画出那条垂直线?怎么走呢?

【问题讨论】:

    标签: python python-3.x plot pyqtgraph errorbar


    【解决方案1】:

    这看起来很像一个错误,应该在the issues page 上报告。编辑:nm,我看到你已经posted there 并且在那里得出了与 mince 相同的结论。

    看起来没有为低于 5e-13 的错误值绘制条形图。您可以看到,如果您将错误乘以 10 甚至 2,就会出现条形。

    目前,我建议将您的 y 值和误差乘以 1e12,并在标签中写下这些值的单位为 pico-units(?)

    【讨论】: