Question

Is it me, or is it impossible to plot points (scatterplot) in pyqtgraph using Python 3.3?

I have quite big data*, and find matplotlib way too slow, so I would like to give this a try:

1) pyqtgraph.plot([1],[1]) shows nothing in the plot.

2) pyqtgraph.plot([1,2,3,4], [1,2,3,4]) shows a line connecting the dots

3) pyqtgraph.plot([1,2,3,4], [1,2,3,4], pen=None) as suggested by docs, errors**

4) pyqtgraph.ScatterPlotItem() does not exist.

I do not know what to try anymore... Did anyone get this working and would be willing to share code?


* I am aware of the irony with the data I present, forgive me.

** TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'.

*** Perhaps unrelated, but I also can't get the examples to run (Ubuntu 13.04).

Was it helpful?

Solution

The correct ways to create a scatter plot are either by specifying the symbol properties when plotting (symbol, symbolPen, symbolBrush, symbolSize; see the PlotDataItem API):

pg.plot([1,2,3,4], [1,2,3,4], pen=None, symbol='o')

Or by directly creating a ScatterPlotItem, which seems to exist on my end:

>>> import pyqtgraph as pg
>>> pg.ScatterPlotItem
<class 'pyqtgraph.graphicsItems.ScatterPlotItem.ScatterPlotItem'>

See examples/ScatterPlot.py on how to use the latter method.

OTHER TIPS

Thank you very much Luke. I was able to find a solution with the help of your reply.

x = np.float64(10.5)
y = np.float64(6.4)
x_gap = (0.001 * x) / 100.0
y_gap = (0.001 * y) / 100.0
x_list = [(x - gap_q), x, (x + gap_q), x]
y_list = [(y), (y + y_gap), y, (y - y_gap)]
pg.plot(x_list, y_list,
              pen=None,
              name="BEP",
              symbol='o',
              symbolPen=pg.mkPen(color=(0, 0, 255), width=0),                                      
              symbolBrush=pg.mkBrush(0, 0, 255, 255),
              symbolSize=7)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top