秉着边学边写边折腾的原则,开始粗糙的工作。真正掌握还是得讲解给别人听。 先给出网课
https://www.icourse163.org/course/BIT-1001871001
Mayavi官方
http://docs.enthought.com/mayavi/mayavi/genindex.html
(有时候这网站会装死,一般过几个小时就会活过来)
我发现了,光是三流操作还不够,还得加上四流翻译。
这篇文章放在来第二章绘图函数的倒数第二篇,最后一篇留出来,考虑到一些补充。
这个文章是一个总结,因为很明显利用参数的不同来说图像绘制并不合理,只是一定程度上地节约篇幅,仅此而已。
不合理体现在,分类方式,比如imshow
居然和plot3d
放在一起。
1.重新来分类
一种比较合理的分类就是按照维度进行分类。
http://docs.enthought.com/mayavi/mayavi/mlab_3d_plotting_functions.html
按维度:
1d:
plot3d()
,points3d()
2d:
imshow()
,surf()
,contour_surf()
,mesh()
,barchart()
,triangular_mesh()
3d
contour3d()
,quiver3d()
,flow()
,volume_slice()
2.Mayavi的管线配置很重要
很多时候绘图的参数都可以GUI设置,我不能说直接设置不好。但是每次画一下都要去GUI一下我是挺不乐意的。
好在Mayavi里面有脚本录制,这个我没说,原因是,脚本录制采用的是管线的写法,超出了第二章的范畴。所以。不多说。
3.数据源同样重要
首先要对Data representation数据表示法很熟悉,这个文,我翻了一半。这个文档相当重要。
第二章也没过多涉及数据源的问题,我始终停留在Module
层级,数据源层级属于Scene
是Module
的父层级,没有过多涉及。
我们目前绘制的都是直接从numpy
生成的干净的数据,直接的数据。而真实情况是,我们往往是从外部读取数据,这里不涉及。后面会慢慢写过来,这是一个很长的过程,需要不少的时间。我也是边学边写,边补充。
-1.写在最后
然后呢,如果系统地看完或者整理过,应该有这样的认识:
0.图像的观察方式,很多都不是用单一的手段,往往是多种绘制有机结合。所以熟悉各种绘制就变得很重要,比如
mesh
绘制了网格面,为了观察值域范围往往要补充outline
,比如volume_slice
本身就不是主要的观察手段,而是辅助观察。
1.绘制函数都是被封装好的,如果要绘图尽可能使用接口。有些高级绘制仅仅依靠绘制函数是不够的,如果要绘制更好的效果,需自己一层一层铺设管线来处理更多的细节。
2.从数据到图,这中间经历了很多过程的,而Mayavi做的工作是可视化,也就是将最后的图像结果呈现出来。
3.如果注意到Mayavi的内部,对于这句话应该是有更多的理解的——The tvtk module (also called TVTK) provides a traits enabled version of VTK. TVTK objects wrap around VTK objects but additionally support traits, and provide a convenient Pythonic API. TVTK is implemented mostly in pure Python (except for a small extension module). Here is a list of current features.
TVTK是纯Python编写,那么Mayavi的GUI做得算是相当好了。那么我就不得不思考Mayavi本身是怎么写出来的,界面确实做得很好~这里用的是TraitsUI而非wxPython和Pyqt在文档里面提到过,不过也可以适当考虑一下。
最最后面,暂时没人注意,也没人看,这无所谓的。我也是边学边写,养成输出的习惯。偶尔觉得,写写也挺好玩的。
——做做翻译,画画图,调调代码,一天就过去了。
就这样。
这个想起了又补充。