0

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.

psubsee2003
  • 8,563
  • 8
  • 61
  • 79
questionhang
  • 735
  • 2
  • 12
  • 31

1 Answers1

3

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'
aestrivex
  • 5,170
  • 2
  • 27
  • 44
  • Could you please make it clear?I tried you way but did not make it. – questionhang Oct 10 '13 at 14:03
  • What part of the answer is not clear? What specifically did you do, and what was the result? – aestrivex Oct 10 '13 at 17:38
  • I revised my post.Please take a look at it. – questionhang Oct 11 '13 at 12:33
  • You are editing the `label_format` attribute of the `mlab.axes` module, before you create any instance of `axes`. This is not what you want. Edit the `label_format` attribute of the axis instance you create. I have updated my answer to isolate the error in the large code snippet you posted. – aestrivex Oct 11 '13 at 14:40
  • Please forgive my retard.Your method works.I forgot the brackets.I have updated my post,how do you know that? – questionhang Oct 13 '13 at 16:08
  • The way I figured this out was with an interactive Ipython session. I just looked at the available traits in the axes object, and saw this one. – aestrivex Oct 15 '13 at 16:15