python plotting with greek symbols within labels recommendations?

  • Thread starter michael.s.gilbert
  • Start date
M

michael.s.gilbert

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.

pygrace (http://www.its.caltech.edu/~mmckerns/software.html) seems to
be able to inherently support symbols, but it doesn't follow the tex
formatting. it has its own (seemingly arbitrary) syntax.

any thoughts on plotting libraries would be much appreciated.

mike
 
R

Robert Kern

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.

You can if you have TeX installed and enable text.usetex in your
configuration. E.g.

In [4]: title('This is $\Gamma$reek to me.')

There isn't much out there that allows a reasonably full range of TeX
without calling out to TeX.

If you want to improve the non-TeX fallback for matplotlib's mathtext
module to support math-mode text embedded in plain text, I'm sure John
would love to see your contribution. It shouldn't be that hard; it's
just nobody's had the motivation to work on it given the availability of
real TeX labels.

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
R

Robert Kern

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.

And, incidentally, if you're only interested in letters and symbols
strung out horizontally with the Latin characters rather than formula
layout, you can use Unicode if your font supports it:

In [41]: s
Out[41]: u'This is \u0393reek to me'

In [42]: rc('font', serif=['Code2000'])

In [43]: title(s)

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
S

skip

mike> thus far, i've found that matplotlib
mike> (http://matplotlib.sourceforge.net/) can do this, albeit the
mike> implementation is so poor that you cannot mix standard text with
mike> symbols on the same plot element.

That seems a bit harsh. Have you asked on the matplotlib mailing list to
see if it can do what you want?

Skip
 
J

Juho Schultz

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.
 
W

wobsta

Hi,

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).

You may want to have a look at PyX (pyx.sourceforge.net), which
features a seamless TeX integration for all typesetting tasks and thus
allows you to use TeX syntax all over the place.

André
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top