Matplotlib expects to find .ttf
fonts on your system. Newer versions of OS X use .dfont
files. Converting them is easy, and putting them in a proper font path is also easy. The user font path on OS X is ~/Library/Fonts/
, and matplotlib will find fonts here.
- First, install what you'll need:
- matplotlib
- fondu (
port install fondu
, orbrew install fondu
)
- Then find your desired font file. For system font files, the easiest way to do this is in the FontBook application. You can open FontBook in your utlities folder. Then select your font of choice, right click on it, and select "Show in Finder". You'll need to know where it is. Many system fonts are in places like
/System/Library/Fonts/...
- Move to your user's font directory
~/Library/Fonts/
. - Use
fondu
to convert the OS-X specific font file (ends with.dfont
) to.ttf
. - Delete your matplotlib font cache,
rm ~/.matplotlib/fontList.cache
- Set your desired font in your matplotlibrc file. That's probably at
~/.matplotlib/matplotlibrc
. You can change the font with entries like the following:
# Fonts
font.serif : Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman
font.sans-serif : Helvetica, Avant Garde, Computer Modern Sans serif
Thanks for posting this! Just add that I had to rebuild the font cache afterwards:
import matplotlib
matplotlib.font_manager._rebuild()