diff --git a/CHANGELOG b/CHANGELOG index f9f9466f..e574e479 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -55,6 +55,7 @@ pyqtgraph-0.9.9 [unreleased] - Added InfiniteLine.setHoverPen - Added GLVolumeItem.setData - Added PolyLineROI.setPoints, clearPoints, saveState, setState + - Added ErrorBarItem.setData Bugfixes: - PlotCurveItem now has correct clicking behavior--clicks within a few px diff --git a/examples/ErrorBarItem.py b/examples/ErrorBarItem.py index 3bbf06d1..cd576d51 100644 --- a/examples/ErrorBarItem.py +++ b/examples/ErrorBarItem.py @@ -7,7 +7,7 @@ Demonstrates basic use of ErrorBarItem import initExample ## Add path to library (just for examples; you do not need this) import pyqtgraph as pg -from pyqtgraph.Qt import QtGui +from pyqtgraph.Qt import QtGui, QtCore import numpy as np import pyqtgraph as pg diff --git a/pyqtgraph/graphicsItems/ErrorBarItem.py b/pyqtgraph/graphicsItems/ErrorBarItem.py index 7b681389..d7cb06db 100644 --- a/pyqtgraph/graphicsItems/ErrorBarItem.py +++ b/pyqtgraph/graphicsItems/ErrorBarItem.py @@ -8,15 +8,7 @@ __all__ = ['ErrorBarItem'] class ErrorBarItem(GraphicsObject): def __init__(self, **opts): """ - Valid keyword options are: - x, y, height, width, top, bottom, left, right, beam, pen - - x and y must be numpy arrays specifying the coordinates of data points. - height, width, top, bottom, left, right, and beam may be numpy arrays, - single values, or None to disable. All values should be positive. - - If height is specified, it overrides top and bottom. - If width is specified, it overrides left and right. + All keyword arguments are passed to setData(). """ GraphicsObject.__init__(self) self.opts = dict( @@ -31,14 +23,35 @@ class ErrorBarItem(GraphicsObject): beam=None, pen=None ) - self.setOpts(**opts) + self.setData(**opts) + + def setData(self, **opts): + """ + Update the data in the item. All arguments are optional. - def setOpts(self, **opts): + Valid keyword options are: + x, y, height, width, top, bottom, left, right, beam, pen + + * x and y must be numpy arrays specifying the coordinates of data points. + * height, width, top, bottom, left, right, and beam may be numpy arrays, + single values, or None to disable. All values should be positive. + * top, bottom, left, and right specify the lengths of bars extending + in each direction. + * If height is specified, it overrides top and bottom. + * If width is specified, it overrides left and right. + * beam specifies the width of the beam at the end of each bar. + * pen may be any single argument accepted by pg.mkPen(). + """ self.opts.update(opts) self.path = None self.update() + self.prepareGeometryChange() self.informViewBoundsChanged() + def setOpts(self, **opts): + # for backward compatibility + self.setData(**opts) + def drawPath(self): p = QtGui.QPainterPath() diff --git a/pyqtgraph/graphicsItems/GraphicsItem.py b/pyqtgraph/graphicsItems/GraphicsItem.py index 9fa323e2..c1a96a62 100644 --- a/pyqtgraph/graphicsItems/GraphicsItem.py +++ b/pyqtgraph/graphicsItems/GraphicsItem.py @@ -318,6 +318,8 @@ class GraphicsItem(object): vt = self.deviceTransform() if vt is None: return None + if isinstance(obj, QtCore.QPoint): + obj = QtCore.QPointF(obj) vt = fn.invertQTransform(vt) return vt.map(obj)