I am sure there is better solutions, but
> title(r"\\delta^\{15\}N \\ and \\ Trophic \\ Level \\ for \\ %s
> \\ Food \\ Web"%name) should already be close to what you
> 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.
> classic python way (replace %s in the string by the
> string appearing after the % operator...) Now I wonder
> if mixing Tex math expression and normal text expression
> is possible, something like: title(r"\\delta^\{15\}N and
> Trophic Level for %s Food Web"%name) Advantange would be
> to use classic font for non-math part, as done in Tex...
> This does not seems to work in matplotlib 0.54.2, but
> 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