Create custom scatterplotitem symbol beside letters

389 views
Skip to first unread message

Friedrich Dinsel

unread,
Jan 18, 2018, 8:47:23 AM1/18/18
to pyqtgraph
hi :-)

i am trying to create my own symbol for a scatterplotitem but can't get it to work. i have tried a few ways described in the documentation and several (well.. there are not that many) examples in the web. from my understanding in the docu i can pass a created QPainterPath to the symbol argument of ScatterPlotItem.. like this:

class Symbols():
   
# something like a bowtie
    valves
= np.asarray([
               
[0.4330127, 0.25],
               
[0.4330127, -0.25],
               
[-0.4330127, 0.25],
               
[-0.4330127, -0.25],
               
[0.4330127, 0.25]
               
])

    valve
= pg.arrayToQPath(valves[:, 0], valves[:, 1], connect='all')
   
# >>> <class 'PyQt5.QtGui.QPainterPath'>



class Show()

# stuff here..

def _showMeSomething(self):
    valve_symbols
= ScatterPlotItem(
                size
=20,
                pen
=pg.mkPen(0, 0, 0, 255),
                brush
=pg.mkBrush(224, 76, 2, 255),
               
# symbol='t',
                symbol
=Symbols.valve
               
)
    spots
= ...
    valve_symbols
.addPoints(spots)
    figure
.add(valve_symbols)

at the point of addPoints i get the following error:
  File "venv3/lib/python3.5/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 409, in addPoints
    self.updateSpots(newData)
  File "venv3/lib/python3.5/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 559, in updateSpots
    sourceRect = self.fragmentAtlas.getSymbolCoords(opts)
  File "venv3/lib/python3.5/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 134, in getSymbolCoords
    sourceRect[i] = self.symbolMap[key]
  File "venv3/lib/python3.5/weakref.py", line 131, in __getitem__
    o = self.data[key]()
TypeError: unhashable type: 'QPainterPath'

could someone help me with that? o.O if a MWE should be necessary i think i can break that down :-)

cheers in advance
friedrich

Mikhail Terekhov

unread,
Jan 29, 2018, 10:45:37 PM1/29/18
to pyqt...@googlegroups.com
It is fixed in the develop branch now. :)

regards

Friedrich Dinsel

unread,
Feb 5, 2018, 8:53:31 AM2/5/18
to pyqtgraph
It is fixed in the develop branch now. :)

sweet! thank you very much!!
Reply all
Reply to author
Forward
0 new messages