gTcV
gTcV

Reputation: 2504

Set font for matplotlib ticks

I want the ticks in matplotlib to be typeset using Computer Modern sans-serif. How do I do this?

I would have expected this would do the trick, but it doesn't:

mpl.rcParams['font.family'] = 'computer modern sans serif'

Upvotes: 0

Views: 165

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169314

Try this:

mpl.rcParams['font.family'] = 'sans-serif'
mpl.rcParams['font.sans-serif'] = ['computer modern']

The font.family property has five values:

  1. 'serif' (e.g., Times),
  2. 'sans-serif' (e.g., Helvetica),
  3. 'cursive' (e.g., Zapf-Chancery),
  4. 'fantasy' (e.g., Western), and
  5. 'monospace' (e.g., Courier).

After setting the font family you provide a list of fonts for matplotlib to try to find in order.

Upvotes: 2

Related Questions