These instructions below are for Mac OS X, and assume you have installed Jupyter.
1. Install homebrew: go to and follow the instruction (no plural) here http://brew.sh/
2. Install font converter `fondu` with homebrew using the command:
brew install fondu
in Terminal. We will used `fondu` to convert the font of choice to 'ttf'.
3. Then find the font file you want to add. Open FontBook in your Utilities folder, find your font of choice, right-click on it, and select "Show in Finder".
4. Copy the font family to the folder "\Library\Fonts".
5. If this font already has the file extension `ttf`, you can skip to step 6.
If the font has file extension `dfont`, enter the following lines in Terminal:
cd \Library\Fonts
fondu <filename of font>
This will convert the .dfont file to a .ttf file.
6. Now we need to delete the font cache for matplotlib. In terminal, enter the lines
cd ~/.matplotlib
ls -l
to navigate to the matplotlib temp directory and list its contents.
7. There should be a file named either `fontList.cache` or `fontList.py3k.cache`. Use
rm <name of fontlist cache>
to delete it.
8. Now we need to edit the matplotlib parameters file. Start a new Python notebook in Jupyter and run the command
import matplotlib
matplotlib.matplotlib_fname()
in a new cell. This should give you something like:
'/Users/YourUserName/anaconda/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc’
which is the location of the parameters file.
9. Open this file in a text editor and scroll down to the Font section.
10. Find the line beginning with `font.sans-serif` and/or `font.serif`. Remove the '#' at the beginning of these lines.
11. Add the name of the font family to these lines. For example:
font.serif : Alegreya, Droid Serif, Bitstream Vera Serif, ...
font.sans-serif : Helvetica Neue, Source Sans Pro, Bitstream Vera Sans…
I have added Alegreya and Droid Serif to the serif family of fonts; Helvetica Neue and Source Sans Pro have been added to the sans-serif family. Matplotlib will look for fonts in running order, so put the fonts you want to use as default immediately after the colon.
11. Save the edited `matplotlibrc` file.
12. Restart your Jupyter notebook and run the following lines.
import matplotlib.pyplot as plt
plt.rcParams
and scroll to the Font section again to check that your settings have taken effect.
13. You can use the following matplotlib commands to change font family (sans-serif or serif) and the font. For example:
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = 'Droid Serif’
You'll need to restart the notebook and run these lines again if you change the font.
14. To ensure that your edited parameters file will not be ignored when using seaborn, you need to import seaborn as
import seaborn.apionly as sns
This is only possible with the latest version of seaborn (v0.7.1).
-Joses Ho