On Thu, Sep 23, 2010 at 8:52 AM, Oz Nahum <nahu...@gmail.com> wrote: > Hi Ryan, > > Thanks for your answer. However, I don't understand from the existing > documentation how to use tickers. > > In the past I used the following method: > class SciFormatter(Formatter): > def __call__(self, x, pos=None): > return "%1.1e" % x > > > axs.yaxis.set_major_formatter(SciFormatter()) > > This still does not allow me to get read of the zeros that matplotlib > coherces . > > I would like to manipulate the strings of the tick labels directly. I know > it's not ideal, but I it should work. > > If I could access the label "1.1E+01", I could tell python just to take > label[:-2] and glue it to label[-1], which will give me > "1.1E+1" > > I would be greatful if someone showed me how to access that string.
Why not just format the number yourself? import matplotlib.pyplot as plt import numpy as np def format(x, pos=None): if x == 0.0: exp = 0 else: exp = int(np.log10(np.abs(x))) mant = x / 10**exp return '%.2fE%+d' % (mant, exp) f = plt.figure() ax = f.add_subplot(111) data = np.array([1,2,3,4,5]) / 100. ax.plot(data, np.arange(len(data))) ax.xaxis.set_major_formatter(plt.FuncFormatter(format)) plt.show() Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users