Not using exponents on y-axis of log graphs

Hi there,

I've got a program that generates a bunch of plots with logarithmic charts.
Matplotlib handles them great, but it seems to by default label the y axis
ticks 10^0, 10^1, 10^2 etc. Is there an way to make it spell out these
numbers instead (ie 1, 10, 100 etc)? I guess I could make custom ticks for
every one, but the graph is not always the same and if it could do it
automatically it would be much better.

Thanks a lot,
Alex

···

--
View this message in context: http://old.nabble.com/Not-using-exponents-on-y-axis-of-log-graphs-tp28155571p28155571.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Make a custom tick formatter:

form = plt.FormatStrFormatter('%d')
plt.gca().yaxis.set_major_formatter(form)

Ryan

···

On Tue, Apr 6, 2010 at 1:16 PM, Alex S <schmitt.happens@...287...> wrote:

I've got a program that generates a bunch of plots with logarithmic charts.
Matplotlib handles them great, but it seems to by default label the y axis
ticks 10^0, 10^1, 10^2 etc. Is there an way to make it spell out these
numbers instead (ie 1, 10, 100 etc)? I guess I could make custom ticks for
every one, but the graph is not always the same and if it could do it
automatically it would be much better.

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Ah thank you very much, that works fine except for decimals... (.1, .01, .001
etc all show as 0). Is there a way to show these as well (preferably
without showing all the rest of the numbers as 1.000, 10.000, 100.000)?
Sorry if this is a very newbie question... I don't know what symbol does
what on the string formatter, is there a web site somewhere that lays it all
out? As per usual, http://matplotlib.sourceforge.net/api/ticker_api.html
the manual has just confused me...

···

--
View this message in context: http://old.nabble.com/Not-using-exponents-on-y-axis-of-log-graphs-tp28155571p28156608.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Thanks again to Mike who explained my problems off list. For other people
trying to do something similar,
http://docs.python.org/library/stdtypes.html#string-formatting here is the
page describing python string formats, and the format i was looking for to
show decimals was '%g' (rather than '%d' which was for integers and so
truncated decimals).

Thanks guys,
Alex

Alex S wrote:

···

Ah thank you very much, that works fine except for decimals... (.1, .01,
.001 etc all show as 0). Is there a way to show these as well (preferably
without showing all the rest of the numbers as 1.000, 10.000, 100.000)?
Sorry if this is a very newbie question... I don't know what symbol does
what on the string formatter, is there a web site somewhere that lays it
all out? As per usual,
http://matplotlib.sourceforge.net/api/ticker_api.html the manual has just
confused me...

--
View this message in context: http://old.nabble.com/Not-using-exponents-on-y-axis-of-log-graphs-tp28155571p28156753.html
Sent from the matplotlib - users mailing list archive at Nabble.com.