TeX $\times$ symbol not working in matplotlib?

Dave Angel davea at davea.name
Fri Apr 18 13:15:50 EDT 2014


gwhite <gwhite at ti.com> Wrote in message:
> Hi,
> 
> 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.
> 

You want a raw string,  as you did correctly in two other places
 in the code. A raw string tells Python not to use the backslash
 as an escape. 

(Chris said backspace,  but he meant backslash)

You specify raw string by the letter r just before the quote. 

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

Change to:

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

-- 
DaveA




More information about the Python-list mailing list