diff --git a/examples/histogram.py b/examples/histogram.py index 057abffd..d9d70d8b 100644 --- a/examples/histogram.py +++ b/examples/histogram.py @@ -15,6 +15,7 @@ win.resize(800,350) win.setWindowTitle('pyqtgraph example: Histogram') plt1 = win.addPlot() plt2 = win.addPlot() +plt3 = win.addPlot() ## make interesting distribution of values vals = np.hstack([np.random.normal(size=500), np.random.normal(size=260, loc=4)]) @@ -27,11 +28,12 @@ y,x = np.histogram(vals, bins=np.linspace(-3, 8, 40)) curve = pg.PlotCurveItem(x, y, stepMode=True, fillLevel=0, brush=(0, 0, 255, 80)) plt1.addItem(curve) +plt2.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) -#plt2.plot(vals, y, pen=None, symbol='o', symbolSize=5) -plt2.plot(vals, y, pen=None, symbol='o', symbolSize=5, symbolPen=(255,255,255,200), symbolBrush=(0,0,255,150)) +#plt3.plot(vals, y, pen=None, symbol='o', symbolSize=5) +plt3.plot(vals, y, pen=None, symbol='o', symbolSize=5, symbolPen=(255,255,255,200), symbolBrush=(0,0,255,150)) ## Start Qt event loop unless running in interactive mode or using pyside. if __name__ == '__main__': diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index ab9c9911..a8c094a9 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -68,6 +68,9 @@ 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 ========== ============================================================================== **Point style keyword arguments:** (see :func:`ScatterPlotItem.setData() ` for more information) @@ -150,6 +153,7 @@ class PlotDataItem(GraphicsObject): 'shadowPen': None, 'fillLevel': None, 'fillBrush': None, + 'stepMode': None, 'symbol': None, 'symbolSize': 10, @@ -456,7 +460,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 = {}