3D scatter plot with GLMeshItem-s

423 views
Skip to first unread message

Matjaz

unread,
Jul 1, 2014, 4:31:12 AM7/1/14
to pyqt...@googlegroups.com
Hello!


I just stumbled upon pyqtgraph couple days ago and i must say it looks really great! However, I am having performance issues with 3D rendering.

I want to make a 3D scatter plot, but it is really important that each point is represented by a 3D body. What I did so far was built lots of cubes with GLMeshItem and moved them to appropriate locations (rotation comes in later). This works OK only for a small set of points. Am I doing something wrong? Code below ...

glview = gl.GLViewWidget()
md = gl.MeshData(vertexes=cube)

for line in xyz:
   m1 = gl.GLMeshItem(meshdata=md, smooth=False, shader='shaded', glOptions='opaque')
   m1.translate(...)
   glview.addItem(m1)..

where cube is a list of vertices 12x3x3. I figure a faster implementation could be produced using openGL or maybe tinkering with pyqtgraph libraries?


Regards!


m

Marmaduke Woodman

unread,
Jul 1, 2014, 5:09:38 AM7/1/14
to pyqt...@googlegroups.com
In this case, you may benefit by switching to a vertex + face representation of your cubes, and build a single larger mesh that contains all your cubes at once by concatenating the small vertex and faces arrays. This should work nicely for many cubes.
 
 

Matjaz

unread,
Jul 1, 2014, 7:47:28 AM7/1/14
to pyqt...@googlegroups.com
Thank you for the tip. I put it all in one mesh. It's super fast now :) The new code is below if anyone finds it useful.

glview = gl.GLViewWidget()

cube
= np.tile(cube, (xyz.shape[0], 1, 1))
xyz = xyz.repeat(36, axis=0).reshape(cube.shape[0], 3, 3)

m1 = gl.GLMeshItem(vertexes=(cube+xyz))
glview.addItem(m1)
Reply all
Reply to author
Forward
0 new messages