How to set zoom factor in Mayavi

余生长醉 提交于 2019-12-11 20:39:40

问题


I am trying to set the zoom factor in Mayavi2, for example:

from mayavi import mlab

mlab.test_plot3d()
mlab.show()
f = mlab.gcf()
cam = f.scene.camera
cam.zoom(0.1)
mlab.draw()

but nothing happens. The zoom is the same as before; have I missed something?


回答1:


It seems that you have just inverted 2 lines. mlab.show() and mlab.draw() !

Try this:

from mayavi import mlab

currfig = mlab.test_plot3d()
mlab.draw()

cam = currfig.scene.camera
for ii in range(100):
  cam.zoom(0.99)
  mlab.draw()

mlab.show()



回答2:


You can use mlab.view(distance=200)

I don't know of a useful scale to tell you what exactly that distance number means though, I use some experimenting to determine good values.



来源:https://stackoverflow.com/questions/25783180/how-to-set-zoom-factor-in-mayavi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!