[Tex/LaTex] the LaTeX code to put a multiplication symbol into a matplotlib title

math-modematplotlibsymbols

Apologies for a very basic question, but this is something that I always forget, and it's a pain to find with google and the like, so I'm putting it here for everyone's future reference.

As far as I recall, it's $\times$ but that's not working in a matplotlib plot title (perhaps because matplotlib doesn't implement that particular symbol?).

I get something like "A imes B" (with imes in latex font) for the title "A $\times$ B".

Best Answer

This example works as expected: (note the r in front of the title string)

#!/usr/bin/env python

import matplotlib.pyplot as plt

plt.title(r'$A \times B$')
plt.plot([0,1,2])
plt.savefig('test.png')

enter image description here

Related Question