SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Alex S <sch...@gm...> - 2010年04月06日 18:16:21
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.
From: Ryan M. <rm...@gm...> - 2010年04月06日 19:02:58
On Tue, Apr 6, 2010 at 1:16 PM, Alex S <sch...@gm...> 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.
Make a custom tick formatter:
form = plt.FormatStrFormatter('%d')
plt.gca().yaxis.set_major_formatter(form)
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Alex S <sch...@gm...> - 2010年04月06日 19:46:45
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.
From: Alex S <sch...@gm...> - 2010年04月06日 20:00:33
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.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /