Hi all, Can I use formulas within the legend command, e.g.

> legend( ('$\sin(x)$', '$\cos(x)$'), loc='upper left')

You can, but there are two problems with your example. One, you need

to be using "raw" strings if you are using single backslashes, eg

r'$\sin(x)$'

the other is that mathtext doesn't recognize \sin, \cos, \exp etc.

(Edin are you out there? If so, this would be something useful to

work on).

You can do the equivalent by setting the font to roman

from pylab import figure, show, nx

x = nx.arange(0.0, 1.0, 0.01)

fig = figure()

ax = fig.add_subplot(111)

ax.plot(x, nx.sin(2*nx.pi*x), 'ro', label=r'$\rm{sin}(x)$')

ax.plot(x, nx.cos(2*nx.pi*x), 'gs', label=r'$\rm{cos}(x)$')

ax.legend(loc='upper center')

show()

but unfortunately the layout is crappy. This is one of the things

Edin will be working on this summer, trying to fix the kerning (by

using a better set of fonts) so the spacing in '(x)' is handled

properly.

If you have access to TeX, dvipng and ghostscript, you can use

"usetext" for better layout.

JDH