Mehdi
Mehdi

Reputation: 1525

Matplotlib alternative for 3D scatter plots

I am having a hard time using Matplotlib to visualize reprojection results of my data in 3 dimensions after applying Principle components analysis or Linear discriminant analysis. After doing a scatter plot, I cannot rotate the data or change the point of view while zooming easily (Rotation axis stays the same even after you zoom, and if you zoom too much points just disappear) and every change takes one second to occur. Matplotlib is very useful but for this specific use case it starts to get very frustrating as it probably wasn't designed for such tasks. Is there an alternative to Matplotlib in Python that can handle 3d scatter plots better and where one could fluidly navigate through the cloud?

An example is shown in the next figure. I have drawn spheres around each data cluster corresponding to a specific class and colored overlapping spheres with red. Now I want to see how these sphere intersect. I think the biggest problem with Matplotlib is that it doesn't allow shifting of the whole graph with the mouse, it only allows rotation around a fixed point, which makes things very messy once you zoom a bit.

enter image description here

Upvotes: 7

Views: 4044

Answers (4)

2080
2080

Reputation: 1417

Using the free and open source Blender 3D modeling and animation program is definitely an option, it supports Python scripting: https://docs.blender.org/api/current/info_quickstart.html

A script as described here lets you add basic geometry: https://blender.stackexchange.com/a/79404/58163 (more here: https://blenderscripting.blogspot.com/2013/05/adding-geometry-to-existing-geometry.html)

Upvotes: 0

Nihl
Nihl

Reputation: 587

matplotlib is not quite mature for 3d graphics : http://matplotlib.org/mpl_toolkits/mplot3d/faq.html

mplot3d was intended to allow users to create simple 3D graphs with the same “look-and-feel” as matplotlib’s 2D plots. Furthermore, users can use the same toolkit that they are already familiar with to generate both their 2D and 3D plots.

I don't think easy navigation in a 3d plot is easily doable (even 3d scaling is not possible without tweaking the lib). mplot3d was not really intended to be a full-fledged 3D graphics library in the beginning, but more a nice addition for people who needed basic 3D and who were acquainted with matplotlib 2D plot structure.

You might want to take a look at MayaVI (which is pretty good) :

MayaVi2 is a very powerful and featureful 3D graphing library. For advanced 3D scenes and excellent rendering capabilities, it is highly recomended to use MayaVi2.

Upvotes: 5

Tony Power
Tony Power

Reputation: 1178

Matplotlib works alright for 3D however, not too fast when interactivity is needed:

https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html

Mayavi is really fast and compatible with Python 3:

https://docs.enthought.com/mayavi/mayavi/mlab.html#id1

Upvotes: 1

Max
Max

Reputation: 9

A very good alternative, but not in Python, is the 3D plot from ILNumerics (http://ilnumerics.net/). It is in .NET

Upvotes: 0

Related Questions