|
From: John H. <jd...@gm...> - 2009-07-11 13:35:23
|
On Tue, Jul 7, 2009 at 4:06 PM, Joseph Smidt<jos...@gm...> wrote: > I have several plots where the scientific notation exponential > overflows to the top of the plot like this: > http://matplotlib.sourceforge.net/examples/pylab_examples/plotfile_demo.html. > > Is there any way to add units to this? So that, if I wanted, the > units would show up in the overflow as: 1e8 m^3 , for meters cubed? > > Also, is there an easy way to add units to the numbers on the x or y > axis in general? Thanks. You can use a custom formatter, eg:: from matplotlib.ticker import FormatStrFormatter ax.xaxis.set_major_formatter(r'$%.4fm^3'$) # using mathtext for the m^3 exponent See http://matplotlib.sourceforge.net/api/ticker_api.html#matplotlib.ticker.FormatStrFormatter and some code examples http://matplotlib.sourceforge.net/search.html?q=codex+Formatter JDH |