Search code examples
pythonvtkmayavi

How to set zoom factor in Mayavi


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?


Solution

  • 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()