Question

Is there a parameter to control that?I can not find it.
I use

import numpy as np
from enthought.mayavi import mlab
from scipy.interpolate import griddata
from enthought.mayavi.modules.axes import Axes

x,y,z =np.loadtxt('mydata',delimiter=',',usecols=(0,1,2),unpack=True)
xi = np.linspace(min(x), max(x),200)
yi = np.linspace(min(y), max(y),200).reshape(200,1) 
zi = griddata((x, y), z, (xi, yi),method='nearest')  
mlab.surf(xi,yi,zi,warp_scale="auto")
mlab.axes.label_format='%.2f'
mlab.axes(xlabel='x', ylabel='y', zlabel='z',ranges=(1000,1100,1200),nb_labels=5)
mlab.show()

and the ticks are like 1.08e+03 and 1.18e+03 in the output figure.I add mlab.axes.label_format='%.2f',but nothing changes.

Was it helpful?

Solution

I don't know if there's a way to specify it at construction using mlab, but you can dig into the tvtk object (edit: actually it is still traited in the mayavi layer) and modify it:

>>> ax=mlab.axes()
>>> ax.axes.label_format
'%-#6.3g'
>>> ax.axes.label_format='%.2f'

Notice that it is the .axes.label_format format of the axis instance you create that you need to modify. ax is an instance of axis.

Your new code is comparable to the following minimal snippet. Notice how this does not operate on the instance of axis, ax.

>>> ax=mlab.axes()
>>> mlab.axes.label_format='%.2f'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top