How to make a scatter chart with different brush settings?

31 views
Skip to first unread message

skas jdji

unread,
Dec 21, 2019, 11:46:30 PM12/21/19
to pyqtgraph
Hello. I want to make a scatter chart with an array that looks like this:

arr = np.array([(0, 1, 50), (1, 2, 30), (2, 3, 10), (3, 2, 30), (4, 1, 50)],dtype=[('x_cor', 'uint32'), ('y_cor', 'uint32'), ('value', 'uint32')])


I can make a scatter chart using arr['x_cor'] and arr['y_cor']


win = pg.GraphicsWindow()

p = win.addPlot()

p.plot( arr['x_cor'], arr['y_cor'], pen=None, symbol='t', symbolPen=None, symbolSize=10, symbolBrush=(100, 100, 255, 50))


Is it possible to set brush parameter as arr['value']?


For example, it's possible to use different symbols or sizes if you set parameters as:


differntSizes = [50, 30, 10, 30, 50]

differntSymbols = ['t', 'd', 'o', 't', 'o']

p.plot( arr['x_cor'], arr['y_cor'], pen=None, symbol=differntSymbols , symbolPen=None, symbolSize=differntSizes, symbolBrush=(100, 100, 255, 50))


But when I try the code below, it doesn't work.


differntDepths = [(100, 100, 255, 50), (100, 100, 255, 10), (100, 100, 255, 30), (100, 100, 255, 10), (100, 100, 255, 50)]

p.plot( arr['x_cor'], arr['y_cor'], pen=None, symbol=differntSymbols , symbolPen=None, symbolSize=differntSizes, symbolBrush=differntDepths)


How can I set different color or depth for each dot?

Grant R

unread,
Dec 22, 2019, 9:36:10 PM12/22/19
to pyqtgraph
The brushes need to be QBrushes. So the following should work:

symbolBrush=[pg.mkBrush(d) for d in differntDepths]
Reply all
Reply to author
Forward
0 new messages