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.


Cheers,
Oz


On Thu, Sep 23, 2010 at 3:37 PM, Ryan May <rma...@gmail.com> wrote:

> On Thu, Sep 23, 2010 at 3:49 AM, Oz Nahum <nahu...@gmail.com> wrote:
> > Hi Everyone,
> >
> > I don't like the default scientific formatting in matplotlib, IMHO the
> > format of having a zero after the exponent is a waste of space in my
> opinion
> > ...
> > What I mean is that mpl is writing zero as:
> > 0.0e+00 or 1.2e-03. IMHO it would suffice just to do 0.0 and 1.2e-3,
> which
> > take less space and looks better (again, imho).
>
> <SNIP>
>
> >
> > As can be seen, the text string is empty before calling show, which is
> > forcing me to show the image . Is there a way to access these labales
> with
> > out calling show() ?
>
> What you want is to set a custom formatter:
>
> http://matplotlib.sourceforge.net/api/ticker_api.html
>
> import matplotlib.pyplot as plt
> f = plt.figure()
> ax = f.add_subplot(111)
> ax.plot([1,2,3,4,5])
> # Formats ticks on the xaxis with the %.2g format string
> ax.xaxis.set_major_formatter(plt.FormatStrFormatter('%.2g'))
> plt.show()
>
> If you can't get what you want using a format string, you can write a
> function that does what you want can create a formatter from that
> using FuncFormatter.
>
> Ryan
>
> --
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
>



-- 
Oz Nahum
Graduate Student
Zentrum für Angewandte Geologie
Universität Tübingen

---

Imagine there's no countries
it isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to