From: John H. <jdh...@ac...> - 2004-07-21 21:24:15
|
>>>>> "Gregory" == Gregory Lielens <gre...@ff...> writes: Gregory> I am sure there is better solutions, but Gregory> title(r"$\delta^{15}N \ and \ Trophic \ Level \ for \ %s Gregory> \ Food \ Web$"%name) should already be close to what you Gregory> want: "\ " add a space and the name is inserted in the You may want to consider also using the roman font for the non-math text from matplotlib.matlab import * plot([1,2,3]) name = 'John' title(r"$\delta^{15}N\ \rm{and\ Trophic\ Level\ for\ %s\ Food\ Web}$"%name) show() FYI: There are other spacing commands '\ ' : normal space, 30% of fontsize '\/' : small space, 10% of fontsize \hspace{frac} : user specified fraction of fontsize See http://matplotlib.sourceforge.net/matplotlib.mathtext.html for more info. Gregory> classic python way (replace %s in the string by the Gregory> string appearing after the % operator...) Now I wonder Gregory> if mixing Tex math expression and normal text expression Gregory> is possible, something like: title(r"$\delta^{15}N$ and Gregory> Trophic Level for %s Food Web"%name) Advantange would be Gregory> to use classic font for non-math part, as done in Tex... Gregory> This does not seems to work in matplotlib 0.54.2, but Gregory> maybe in 0.60.2? Or in future version? ;-) It doesn't work now (see link above). It may be included in a future version. Wouldn't be too hard.... One problem with the approach above is that mathtext doesn't currently use kerning data, so roman strings like \rm{and \ Trophic \ Level \ for \ %s \ Food\ Web} have nonideal interletter spacing. Kerning is on the list of things to do, which would make the solution above pretty good. I agree that allowing nested "some string $subexpr$" would be better. JDH |