Matplotlib替代3D散点图

时间:2015-07-28 10:44:44

标签: python matplotlib scatter3d

在应用主成分分析或线性判别分析后,我很难使用Matplotlib在3维中可视化数据的重投影结果。在进行散点图后,我无法在轻松缩放时旋转数据或更改视点(即使在缩放后旋转轴保持不变,如果缩放太多点也会消失),每次更改都需要一秒钟。 Matplotlib非常有用,但对于这个特定的用例,它开始变得非常令人沮丧,因为它可能不是为这些任务设计的。在Python中是否有替代Matplotlib可以更好地处理三维散点图,哪一个可以在云中流畅地导航?

下图中显示了一个示例。我在每个数据簇周围绘制了与特定类对应的球体,并用红色绘制了重叠的球体。现在我想看看这些球体是如何相交的。我认为Matplotlib最大的问题在于它不允许用鼠标移动整个图形,它只允许在固定点周围旋转,这使得一旦你缩放就会让事情变得非常混乱。

this discussion

3 个答案:

答案 0 :(得分:4)

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.

Note that unlike matplotlib, MayaVI is not yet compatible with Python3 (and might not be in the foreseeable future), so you'll need a Python2 installation.

答案 1 :(得分:0)

一个非常好的选择,但不是在Python中,是来自ILNumerics(http://ilnumerics.net/)的3D绘图。它在.NET中

答案 2 :(得分:0)

Matplotlib可以很好地用于3D,但是在需要交互性时并不太快:

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

Mayavi确实非常快速,并且与Python 3兼容:

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