TeX $\times$ symbol not working in matplotlib?

Chris “Kwpolska” Warrick kwpolska at gmail.com
Fri Apr 18 12:24:55 EDT 2014


On Fri, Apr 18, 2014 at 6:18 PM, gwhite <gwhite at ti.com> wrote:
> I am trying to understand how to get the TeX "\times" symbol to work.  It is in the title() string in the code I pasted in.  The "\circ" symbol seems fine, by comparison.  "\times" ends up as "imes" in the figure title.
>
> I am probably doing something dumb (hey, maybe a lot of dumb things!), but if you can spot and describe my mistake, I would be quite happy about that.

> plt.title('$\mathrm{poles}$ $(\times)$ \
>            $\mathrm{\&}$ $\mathrm{zeros}$ \
>            $(\circ)$ $\mathrm{of}$ $T(s)T(-s)$',\
>            fontsize=16)

You’re using a regular string.  In which backspaces can be used in
escapes.  \t is one of those escapes, it is the tab character.  In
order to fix, add the letter "r" before the opening quote.  Like this:

> plt.title(r'$\mathrm{poles}$ $(\times)$ \
>            $\mathrm{\&}$ $\mathrm{zeros}$ \
>            $(\circ)$ $\mathrm{of}$ $T(s)T(-s)$',\
>            fontsize=16)

Moreover, in the next two things, you already did it right in the first place:

> plt.xlabel(r'$\sigma$', fontsize=16)
> plt.ylabel(r'$\mathrm{j}\omega$', fontsize=16)

-- 
Chris “Kwpolska” Warrick <http://kwpolska.tk>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense



More information about the Python-list mailing list