Plotting a directed graph

105 views
Skip to first unread message

Fernando Chaure

unread,
Oct 4, 2022, 11:13:29 PM10/4/22
to pyqtgraph
Hello, I have been porting a few GUIs to pyqtgraph, and its amazing and really fast. But I don't know how is the best way to plot a directed graph. I tried with  pyqtgraph.GraphItem, but I need the direction of the edges. Is there a way to add arrow heads to to the edges?


Best,
Fernando



Martin Chase

unread,
Oct 5, 2022, 8:32:01 PM10/5/22
to pyqt...@googlegroups.com
Hey Fernando,

The graph/network support in PyQtGraph isn't very extensive, and this isn't something that comes built in. As a first pass on implementing this, I would build a bunch of CurveArrows at the mid-points of all the edges ( and make sure to set `pxMode` to false or it'll be a messy zoom experience ). Put in a new kwarg ( "showEdgeDirection"? or perhaps more flexibility with an "edgeSymbols" optional list ) on `GraphItem.setData`, make sure the performance isn't egregious ( mostly just finding all those angles and midpoints efficiently ), and that's nearly everything you'll need for a PR!

Regards,
 - Martin
Reply all
Reply to author
Forward
0 new messages