How to plot proper 3D axes in MayaVi, like those f

2020-06-11 13:57发布

问题:

I would like to know how to have proper axes on a 3D surface plot in MayaVi. The best axes I could create looked something like this...

However, these do not look very professional if I were to give a presentation or put these on a poster.

I would like the axes to look something like this...

These axes look much more professional and are easier to read than the default MayaVi axes.

Any help would be greatly appreciated.

Thanks!

回答1:

I had this problem too. I hacked a bad workaround by not displaying the mayavi axes, but plotting the axes I needed myself using plot3d()

from mayavi import mlab
import numpy as np
xx = yy = zz = np.arange(-0.6,0.7,0.1)
xy = xz = yx = yz = zx = zy = np.zeros_like(xx)    
mlab.plot3d(yx,yy+lensoffset,yz,line_width=0.01,tube_radius=0.01)
mlab.plot3d(zx,zy+lensoffset,zz,line_width=0.01,tube_radius=0.01)
mlab.plot3d(xx,xy+lensoffset,xz,line_width=0.01,tube_radius=0.01)

You can now add labels and annotations using text3d() Very inelegant and brute force, but works in a pinch.