1

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".

  • 2
    \times or \cdot comes with any basic installation. Please, add an example. – Sigur Apr 27 '15 at 10:23
  • I was mostly intending to put it here as a reference, so it could be found more easily. But the problem I have has been solved by @Henri's answer.. so perhaps I'll rephrase the question and google will find it for those seeking 'multiplication symbol'. – drevicko Apr 27 '15 at 11:06
4

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

  • 2
    yep, it was the missing r – drevicko Apr 27 '15 at 11:07
  • Is it just an artifact of the resolution of the screenshot, or is the \times-B spacing really that much tighter that the A-\times spacing in the output? – Paul Gessler Apr 27 '15 at 11:09
  • Interesting. I get the same effect. There's a technical name for calculating inter-character spacing when italics and the like are at play. Such typsetting effects are indeed a dark art! – drevicko Apr 27 '15 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.