On Thu, Jul 15, 2010 at 8:41 AM, Waléria Antunes David
<waleriantu...@gmail.com> wrote:
> Hi all,
>
> I have a code base so that:
>
>
> from pylab import *
> x = arange (3000,3400)
> y = -108 * (3.0e14 ** 2)/x**2
>
> pylab..title("Teste")
> pylab.savefig("imagem.png")
> plot(x, y)
>
>
> Well.... the values of the function range(3000,3400) are in Hz......i need
> to pass GHz which would be in scientific notation as follows bellow:
>
> 3000 Hz = 3,0 × 10-6 GHz
> 3400 Hz = 3,4 x 10-6 Ghz
>
> How do I make the graph x-axis is shown in figures
> scientific notation, for this currently so
>
> 3000,3050,3100,....,3400
>
> in scientific notation is: (3.0e-6,  3.4e-6)

One way is to just change the values in the GHz and plot them:

plot(x/1e9, y)
# Need to change some limits so that they show up in scientific notation:
gca().xaxis.get_major_formatter().set_powerlimits((-5,5))

The other way is make a custom formatter that changes the values of the ticks:

def fmt_ghz(val, pos=None):
    return '%g' % (val / 1e9)

plot(x, y)
gca().xaxis.set_major_formatter(FuncFormatter(fmt_ghz))

You can get more information here:
http://matplotlib.sourceforge.net/api/ticker_api.html

Ryan

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

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to