6

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

Mehdi
  • 1,370
  • 3
  • 15
  • 26
  • Not sure specifically what your problem is without code but have you looked here: http://pythonprogramming.net/matplotlib-3d-scatterplot-tutorial/ – jfish003 Jul 28 '15 at 10:52
  • as I just said, Matplotlib doesn't allow a nice rotation and zooming on the cloud. And it lags like hell when you plot few thousand points. – Mehdi Jul 28 '15 at 11:08
  • You could use a triangle plot to show the different projections from K-dimensional space onto 2D (https://github.com/dfm/triangle.py) – Daniel Lenz Jul 28 '15 at 11:47
  • matplotlib is not quite mature for 3d graphics : http://matplotlib.org/mpl_toolkits/mplot3d/faq.html . I don't think easy navigation in a 3d plot is possible (even 3d scaling is not possible without tweaking the lib). You might want to take a look at MayaVI. – Nihl Jul 28 '15 at 13:10
  • 1
    @Nihl Thanks a lot, Mayavi is exactly what I needed :), you could change it into an answer. – Mehdi Jul 28 '15 at 15:07

3 Answers3

5

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.

Doron Behar
  • 2,606
  • 2
  • 21
  • 24
Nihl
  • 557
  • 1
  • 5
  • 14
0

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

dsh
  • 12,037
  • 3
  • 33
  • 51
Max
  • 9
  • 1
0

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

Tony Power
  • 1,033
  • 11
  • 23