jupyter notebook中使用mayavi三维绘图库

jupyter notebook中使用mayavi三维绘图库

就像绘图时可使把matplotlib嵌入jupyter中一样,mayavi也在jupyter notebook中嵌入式使用。

以下假定已经安装好了jupyter notebook和mayavi库。

1. 安装需要的python依赖

pip install ipywidgets ipyevents

2. 进行设置

命令行中输入以下命令即可:

$ jupyter nbextension install --py mayavi --user
$ jupyter nbextension enable --py mayavi --user

3. 开始使用

打开jupyter notebook,在正式开始使用mayavi绘图前,调用mayavi.mlab.init_notebook()函数即可。

from mayavi import mlab
mlab.init_notebook()

此后,mlab绘制出来的三维图即可内嵌于jupyter之中了。这样嵌在jupyter中的三维图也是可以用鼠标对其进行拖动旋转等操作的哦~

posted @ 2020-12-08 21:09  _荒流  阅读(1918)  评论(0编辑  收藏  举报