## Re: [Matplotlib-users] formatting axis to percent notation

 Re: [Matplotlib-users] formatting axis to percent notation From: Michael Droettboom - 2008-01-17 13:57:39 ```John Hunter wrote: > On Jan 16, 2008 1:03 PM, Kevin Christman wrote: > def myfunc(x, pos=0): > return '%1.2f''%(100*x) And you may want to try: def myfunc(x, pos=0): return '%1.2f%%''%(100*x) to get a percent sign after each value. (I mention it only because the "double percent" trick is non-obvious to many newcomers to Python's string formatting syntax.) Cheers, Mike -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA ```

 [Matplotlib-users] formatting axis to percent notation From: Kevin Christman - 2008-01-16 19:03:24 ```I'm new to matplotlib. Currently the x-axis shows numbers from 0 to 1. I would like it to show it in percent notation (e.g. 0% to 100%). How do I do this in matplotlib? Thanks, Kevin ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ ```
 Re: [Matplotlib-users] formatting axis to percent notation From: John Hunter - 2008-01-16 21:06:53 ```On Jan 16, 2008 1:03 PM, Kevin Christman wrote: > > I'm new to matplotlib. Currently the x-axis shows numbers from 0 to 1. > I would like it to show it in percent notation (e.g. 0% to 100%). > How do I do this in matplotlib? You can either multiply your x data by 100 (where x is a numpy array) >>> plot(x*100, y) or set a custom formatter from matplotlib.ticker import FuncFormatter def myfunc(x, pos=0): return '%1.2f''%(100*x) ax = subplot(111) ax.plot(x, y) ax.xaxis.set_major_formatter(FuncFormatter(myfunc)) There is a section on custom tick formatting in the user's guide on the web site JDH JDH ```
 Re: [Matplotlib-users] formatting axis to percent notation From: Michael Droettboom - 2008-01-17 13:57:39 ```John Hunter wrote: > On Jan 16, 2008 1:03 PM, Kevin Christman wrote: > def myfunc(x, pos=0): > return '%1.2f''%(100*x) And you may want to try: def myfunc(x, pos=0): return '%1.2f%%''%(100*x) to get a percent sign after each value. (I mention it only because the "double percent" trick is non-obvious to many newcomers to Python's string formatting syntax.) Cheers, Mike -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA ```