Change default font

Hi,

is there a way to change the default font, e.g., to Times New Roman?! I've been looking at the rcparams but it's kind of confusing.

Cheers.

Hi,

is there a way to change the default font, e.g., to Times New Roman?!
I've been looking at the rcparams but it's kind of confusing.

Cheers.

Yes, but first you should make sure the font is on your system and is of the correct type, i.e. TrueType (TTF). AND you have to make sure know the name of it (some fonts may have names that aren't obvious). To check the name, type the following in the python interpreter:

from matplotlib import font_manager
font_manager.findfont('Times New Roman')

If the font manager finds it, then it should return the path to a ttf file with a similar name; otherwise, it'll return some default font (on my system Vera.ttf).

Assuming you've got all that sorted out, you can set the default font in each script, or in your matplotlibrc file (i.e. globally). But first note that Times New Roman is a serif font; matplotlib uses sans-serif fonts by default (at least on my system). So if you decide to go with Times New Roman, or another serif font, you need to change the font family, as well. Here's some examples

1) In a script, add:

import matplotlib.pyplot as plt
plt.rc('font', family='serif')
plt.rc('font', serif='Times New Roman')

2) In your matplotlibrc file, add:

font.family: serif
font.serif: Times New Roman

Best,
-Tony

ยทยทยท

On Sep 1, 2010, at 5:10 PM, Ali Fessi wrote: