Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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...

enter image description here

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...

enter image description here

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

Any help would be greatly appreciated.

Thanks!

like image 526
Ben Donovan Avatar asked Jun 19 '14 13:06

Ben Donovan


People also ask

Are 3D graphs possible in matplotlib?

We can create 3D plots in Python thanks to the mplot3d toolkit in the matplotlib library. Matplotlib was introduced with only 2D plots in mind. However, as of the 1.0 release, 3D utilities were developed on top of 2D, so 3D implementations of data are available today.

What is mlab in python?

Mlab is a high-level python to Matlab bridge that lets Matlab look like a normal python library.


1 Answers

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.

like image 192
Etherealwings Avatar answered Sep 16 '22 11:09

Etherealwings