Q:

Import of Open Sans Font in matplotlibrc Ubuntu fails

I try to import the Font Open Sans over:
import matplotlib as mpl
#update matplotlibrc
mpl.rcParams['font.family'] = 'Open Sans'

#testplot
import matplotlib.pyplot as plt
plt.plot(range(10))
plt.title('Everything is crazy!!!', size=32)
plt.show()

If I want to plot, the font can't be found by matplotlib, giving an error message like:
/usr/lib/pymodules/python2.7/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['Open Sans'] not found. Falling back to Bitstream Vera Sans
      (prop.get_family(), self.defaultFamily[fontext]))

/usr/lib/pymodules/python2.7/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=light:stretch=normal:size=medium. Returning /usr/share/matplotlib/mpl-data/fonts/ttf/cmb10.ttf
      UserWarning)

The font is installed in Ubuntu and all the OpenSans-*.ttf Files are also copied to the matplotlib folder (/usr/share/matplotlib/mpl-data/fonts/ttf/ in Ubuntu).
Any Idea how to use the font in the matplotlibrc?

A:

Ok this is an old question but I've just installed Open Sans for use in Matplotlib too:
The OP has followed the correct steps, except needs to force the Matplotlib font cache to rebuild. The easiest way of doing this:
from matplotlib import font_manager
font_manager._rebuild()

Note than on Linux, as well as the Font paths discussed above Matplotlib appears to also search in ~/.fonts, so you can install fonts there.

