diff --git a/CHANGELOG b/CHANGELOG index 66544979..934e6952 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -47,6 +47,7 @@ pyqtgraph-0.9.9 [unreleased] - PeriodicTrace used to report deadlocks - Added AxisItem.setStyle() - Added configurable formatting for TableWidget + - Added 'stepMode' argument to PlotDataItem() Bugfixes: - PlotCurveItem now has correct clicking behavior--clicks within a few px diff --git a/examples/histogram.py b/examples/histogram.py index 057abffd..2674ba30 100644 --- a/examples/histogram.py +++ b/examples/histogram.py @@ -2,8 +2,6 @@ """ In this example we draw two different kinds of histogram. """ - - import initExample ## Add path to library (just for examples; you do not need this) import pyqtgraph as pg @@ -22,11 +20,9 @@ vals = np.hstack([np.random.normal(size=500), np.random.normal(size=260, loc=4)] ## compute standard histogram y,x = np.histogram(vals, bins=np.linspace(-3, 8, 40)) +## Using stepMode=True causes the plot to draw two lines for each sample. ## notice that len(x) == len(y)+1 -## We are required to use stepMode=True so that PlotCurveItem will interpret this data correctly. -curve = pg.PlotCurveItem(x, y, stepMode=True, fillLevel=0, brush=(0, 0, 255, 80)) -plt1.addItem(curve) - +plt1.plot(x, y, stepMode=True, fillLevel=0, brush=(0,0,255,150)) ## Now draw all points as a nicely-spaced scatter plot y = pg.pseudoScatter(vals, spacing=0.15) diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index ab9c9911..3e760ce1 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -68,6 +68,10 @@ class PlotDataItem(GraphicsObject): fillLevel Fill the area between the curve and fillLevel fillBrush Fill to use when fillLevel is specified. May be any single argument accepted by :func:`mkBrush() ` + stepMode If True, two orthogonal lines are drawn for each sample + as steps. This is commonly used when drawing histograms. + Note that in this case, `len(x) == len(y) + 1` + (added in version 0.9.9) ========== ============================================================================== **Point style keyword arguments:** (see :func:`ScatterPlotItem.setData() ` for more information) @@ -150,6 +154,7 @@ class PlotDataItem(GraphicsObject): 'shadowPen': None, 'fillLevel': None, 'fillBrush': None, + 'stepMode': None, 'symbol': None, 'symbolSize': 10, @@ -456,7 +461,7 @@ class PlotDataItem(GraphicsObject): def updateItems(self): curveArgs = {} - for k,v in [('pen','pen'), ('shadowPen','shadowPen'), ('fillLevel','fillLevel'), ('fillBrush', 'brush'), ('antialias', 'antialias'), ('connect', 'connect')]: + for k,v in [('pen','pen'), ('shadowPen','shadowPen'), ('fillLevel','fillLevel'), ('fillBrush', 'brush'), ('antialias', 'antialias'), ('connect', 'connect'), ('stepMode', 'stepMode')]: curveArgs[v] = self.opts[k] scatterArgs = {}