How to draw thousands of lines?

108 views
Skip to first unread message

Newbie

unread,
Dec 28, 2016, 3:56:31 AM12/28/16
to pyqtgraph
For a network visualization algorithm, I need to draw thousands of lines in 3D space, each in different color and width. Currently I'm using gl.GLLinePlotItem create these lines and add them within a for-loop. As expected, it's extremely slow. Any suggestions to improve the performances?
(I checked another topic on the similar problem, but unable to adapt that solution to my problem.)

Also, I need to draw curved lines in 3D space? Do I have to use small segments of straight lines that are created using gl.GLLinePlotItem? Is there any other technique?

David Palmer

unread,
Jan 4, 2017, 5:50:23 PM1/4/17
to pyqtgraph
Can you draw one continuous line with many points, and a different pen for each segment?  So instead of having n pairs of points you have 2n points, and have the pen be alternatingly the color/width you want (between endpoints of a segment) and None (going to the next segment).

I know that pg.PlotDataItem() takes a connect= argument.  If you can get by with a smaller number of line widths and colors (because 2.3 pixels wide in color #f37492 is visually indistinguishable from 2.1 pixels wide #f76f93) you can group the line segments into a few dozen classes and draw each group separately.

Preston Hinkle

unread,
Jan 6, 2017, 9:10:55 PM1/6/17
to pyqtgraph
I had a similar question earlier and posted this thread:


I haven't implemented it yet, but it may work for you.

Edmon Silva

unread,
Jan 10, 2017, 4:08:33 AM1/10/17
to pyqtgraph
Thanks for your reply, but I couldn't get it running.
Reply all
Reply to author
Forward
0 new messages