Plotting a truncated cone frustrum in PyQtGraph

481 views
Skip to first unread message

Gary Bhumbra

unread,
Jul 21, 2014, 10:39:26 AM7/21/14
to pyqt...@googlegroups.com
First of all, I wanted to send a message of thanks and support to Luke for his generous contribution to the scientific Python-programming community. Although matplotlib suffices for figures (admittedly I prefer Asymptote for this), it never provided a proper GUI-based data display. Now (after a number of tweaks to a few pyqtgraph objects), I can visualise and analyse Axon-based neurophysiology files without the pain of Axon-based software!

However, sticking with the neuro-theme, I was hoping to use pyqtgraph to draw models in which the basic 3D element is a truncated cone frustrum (i.e. think of a 3D cone sitting of it's base with it's pointed end sliced off transversely). Although the provided 3D examples are very impressive, I couldn't find an obvious way to code such a 3D object. I guess it's possible to create such a shape as a 3D-graph surface (á la MATLAB `surf'), but I would like to be able to rotate each object independently and freely in all axes. I would be grateful if anyone could point me in the right direction?

Kind regards,

Gary.

Luke Campagnola

unread,
Jul 22, 2014, 11:04:30 AM7/22/14
to pyqt...@googlegroups.com
On Mon, Jul 21, 2014 at 10:39 AM, Gary Bhumbra <bhu...@gmail.com> wrote:
First of all, I wanted to send a message of thanks and support to Luke for his generous contribution to the scientific Python-programming community. Although matplotlib suffices for figures (admittedly I prefer Asymptote for this), it never provided a proper GUI-based data display. Now (after a number of tweaks to a few pyqtgraph objects), I can visualise and analyse Axon-based neurophysiology files without the pain of Axon-based software!

However, sticking with the neuro-theme, I was hoping to use pyqtgraph to draw models in which the basic 3D element is a truncated cone frustrum (i.e. think of a 3D cone sitting of it's base with it's pointed end sliced off transversely). Although the provided 3D examples are very impressive, I couldn't find an obvious way to code such a 3D object. I guess it's possible to create such a shape as a 3D-graph surface (á la MATLAB `surf'), but I would like to be able to rotate each object independently and freely in all axes. I would be grateful if anyone could point me in the right direction?

Have a look at the cylinder method in the latest branch:
https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/opengl/MeshData.py#L476
The ability to set the radii of either end independently was added for exactly your use case :)

Incidentally, we also have a little project for visualizing neuron morphology and membrane properties; you might find some of this useful: https://github.com/lcampagn/neuronvis/blob/master/hoc_graphics.py
In particular, the "surface" representation makes nice organic-looking models, and the "cylinder" representation sounds like what your are working toward.

Luke

Gary Bhumbra

unread,
Jul 29, 2014, 12:35:41 PM7/29/14
to pyqt...@googlegroups.com
Thanks Luke,


On Tuesday, July 22, 2014 4:04:30 PM UTC+1, Luke Campagnola wrote:
Have a look at the cylinder method in the latest branch:
https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/opengl/MeshData.py#L476
The ability to set the radii of either end independently was added for exactly your use case :)
 
My present install didn't have cylinder in pyqtgraph.opengl.MeshData but your link's cylinder() function works perfectly when combined with `scale' and `translate' to position and orientate each truncated cone.

Incidentally, we also have a little project for visualizing neuron morphology and membrane properties; you might find some of this useful: https://github.com/lcampagn/neuronvis/blob/master/hoc_graphics.py
In particular, the "surface" representation makes nice organic-looking models, and the "cylinder" representation sounds like what your are working toward.

Thanks for the link. I've already got some Asymptote code up my sleeve for pseudo-coloring neural segments according to quantitative measures. Unfortunately, although the underlying 3D rendering engine is also OpenGL, it's just too slow; this restricts the use of Asymptote to publication figures - though it's very good at it. Since I wrote some Python software to visualise and analyse Axon's ABF data files using PyQtGraph (it's available online if you're interested), I've a good idea how much faster the OpenGL rendering is! So my plan is simply to port my Asymptote code to Python using your recommended cylinder() function as the workhorse to render the models. Thanks again for everything!
Reply all
Reply to author
Forward
0 new messages