On Tue, Jul 7, 2009 at 4:06 PM, Joseph Smidt<josephsm...@gmail.com> 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

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to