nicely formatted exponential in title

I tried:

plt.title (r'$\omega=%s$' % omega), where omega=-1e-5. The title says:

omega=-1e-05

with the 'e' in italics, and the whole thing generally ugly.

What I'd like to see is what TeX would do for $1 \times 10^{5}$.

I know mpl already can nicely format numbers for axis. Can I somehow use that
mechanism to nicely format numbers in my title (or other places)?

Have you tried latex_float() as suggested here ?

def latex_float(f):
     float_str = "{0:.2g}".format(f)
     if "e" in float_str:
         base, exponent = float_str.split("e")
         return r"{0} \times 10^{{{1}}}".format(base, int(exponent))
     else:
         return float_str

title (r'\\omega=%s' % latex_float(omega))

ยทยทยท

Am 20.11.2013 19:00, schrieb Neal Becker:

I tried:

plt.title (r'\\omega=%s' % omega), where omega=-1e-5. The title says:

omega=-1e-05

with the 'e' in italics, and the whole thing generally ugly.

What I'd like to see is what TeX would do for 1 \\times 10^\{5\}.

I know mpl already can nicely format numbers for axis. Can I somehow use that
mechanism to nicely format numbers in my title (or other places)?

------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options