From: John H. <jdh...@ac...> - 2005-06-01 15:02:31
|
>>>>> "Nicolas" == Nicolas Girard <nic...@ne...> writes: Nicolas> Hi all, I need to mix maths & text in labels such as Nicolas> title and xlabel. Nicolas> I first tried the most intuitive way: Nicolas> title(r"$x$ and $y$") Nicolas> but it appeared not to work (don't focus of my silly Nicolas> sample title, the real one does make sense ;-) Nicolas> Then I tried Nicolas> title(r"$x$ \text{and} $y$") Nicolas> but I got an error related to the fact that Nicolas> is_string_like() returned False when passing my title Nicolas> 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 |