minor cleanup

This commit is contained in:
Luke Campagnola 2014-04-12 18:01:50 -04:00
parent ac90bf4c3b
commit 98dec9e954
2 changed files with 6 additions and 11 deletions

View File

@ -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
@ -15,7 +13,6 @@ 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)])
@ -23,17 +20,14 @@ 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)
plt2.plot(x, y, stepMode=True, fillLevel=0, brush=(0,0,255,150))
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)
#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))
#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))
## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':

View File

@ -70,7 +70,8 @@ class PlotDataItem(GraphicsObject):
May be any single argument accepted by :func:`mkBrush() <pyqtgraph.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
Note that in this case, `len(x) == len(y) + 1`
(added in version 0.9.9)
========== ==============================================================================
**Point style keyword arguments:** (see :func:`ScatterPlotItem.setData() <pyqtgraph.ScatterPlotItem.setData>` for more information)