# How to mix maths & text in labels ?

Hi all, I need to mix maths & text in labels such as

> title and xlabel.

> I first tried the most intuitive way:

> title(r"$x$ and $y$")

> but it appeared not to work (don't focus of my silly
> sample title, the real one does make sense

> Then I tried

> title(r"$x$ \text{and} $y$")

> but I got an error related to the fact that
> is_string_like() returned False when passing my title
> string to it.

Currently, matplotlib mathtext handling does not allow "embedded" math
expressions. So the whole expression must be written in math mode.
This is a pain and something we will fix when we can.

In the next release of matplotlib, due out soon, we have support for
mathematical expressions using TeX in the *Agg and PS backends. So if
you have tex (and a few other tools) installed on your systems, you
can use it to render all the text in your matplotlib figure.

In the meantime, you can do something like this

title(r'$x\ \rm{and}\ y$')

JDH

Currently, matplotlib mathtext handling does not allow "embedded" math
expressions. So the whole expression must be written in math mode.
This is a pain and something we will fix when we can.

Okay.

In the next release of matplotlib, due out soon, we have support for
mathematical expressions using TeX in the *Agg and PS backends. So if
you have tex (and a few other tools) installed on your systems, you
can use it to render all the text in your matplotlib figure.

In the meantime, you can do something like this

title(r'$x\ \rm{and}\ y$')

Yes, that works fine here ! Many thanks for the tip !

Cheers,
Nicolas

···

On Wednesday 01 June 2005 17:00, John Hunter wrote:

John Hunter wrote:

In the next release of matplotlib, due out soon, we have support for
mathematical expressions using TeX in the *Agg and PS backends.

Wonderful! this is great news. How have you done it? Have you written a DVI driver? or do you use TeX and associated tools to create a bitmap and put that on the image? Or something else?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...