# python plotting with greek symbols within labels recommendations?

Juho Schultz juho.schultz at helsinki.fi
Wed Oct 5 09:10:31 CEST 2005

michael.s.gilbert at gmail.com wrote:
> hello all,
>
> this message is geared toward those of you in the scientific community.
> i'm looking for a python plotting library that can support rendering
> greek symbols and other various characters on plot axes labels, etc. I
> would prefer something that adheres to tex formatting (as implemented
> in latex, matlab, etc and has the form $\alpha$ to represent the greek
> character alpha for example).
>
> thus far, i've found that matplotlib
> (http://matplotlib.sourceforge.net/) can do this, albeit the
> implementation is so poor that you cannot mix standard text with
> symbols on the same plot element.
>
>

If you already have installed matplotlib, have a look at
matplotlib-0.X.Y/examples/tex_demo.py
It shows you how to mix text and symbols.
The other examples in the directory could also be useful.

Essentially you need to remember
matplotlib.rc('text', usetex=True)
before plotting.

If you need complex stuff (fractions, sums, integrals) try
putting an r before the string: pylab.ylabel(
r"Density \$\left(\rho =\frac{x^2+\frac{x+1}{x-1}}{\kappa(x)K_{ij}}\right)")
works fine, at least on my system.