cannot change font to Helvetica in Matplotlib in Python on Mac OS X 10.6
The solution is to use fondu to convert the .dfont Helvetica font from Mac OS X into .ttf, and then place that in the mpl-data/fonts directory that Matplotlib looks in. That solved the issue.
Step-by-step solution for OS X 10.11 El Capitan and Python 3 (based on this post).
- Install fondu:
brew install fondu
Find out matplotlib location:
python3 -c "import matplotlib ; print(matplotlib.matplotlib_fname())"
For me it's
/usr/local/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc
Make a copy of Helvetica:
mkdir ~/Desktop/font_copies cp /System/Library/Fonts/Helvetica.dfont ~/Desktop/font_copies
Convert the Helvetica copy we've made from
dfont
tottf
:cd /usr/local/lib/python3.5/site-packages/matplotlib/mpl-data/fonts/ttf/ fondu -show ~/Desktop/font_copies/Helvetica.dfont
Remove font cache:
rm ~/.matplotlib/fontList.py3k.cache
Done! Now you can use Helvetica:
import matplotlib.pyplot as plt
plt.rc('font', family='Helvetica')