Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On a Ubuntu 12.04 machine, whenever I plot something I get an error like:

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

which I cannot find a solution to online. The following code reproduces the error

import pylab as plt
plt.title("This should be monospaced")

and also the matplotlib self test gives this error:

python -c "import matplotlib as m ; m.test(verbosity=1)"

In ~/.matplotlib/matplotlibrc I have:

font.family         : monospace
font.style          : normal
font.variant        : normal
font.weight         : medium
font.stretch        : normal
font.size           : 10.0
font.serif          : Palatino, Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Charter, serif
font.sans-serif     : Helvetica, Bitstream Vera Sans, sans-serif
font.monospace      : Monaco, Ubuntu Mono Regular, Bitstream Vera Sans Mono, Andale Mono, Nimbus Mono L, Fixed, Terminal, monospace

Some things that do not solve the problem for me:

  1. Delete files in ~/.matplotlib/ (i.e. matplotlibrc, fontList.cache, tex.cache/)
  2. Change the font.family property in ~/.matplotlib/matplotlibrc
  3. Re-install matplotlib after an apt-get purge

The versions I use are:

  • matplotlib 1.1.1~rc1+git20120423-0ubuntu1
  • Python 2.7.3
  • IPython 0.12.1
  • Ubuntu 12.04
share|improve this question

3 Answers 3

Probably it isn't loading your matplotlibrc config file. Make sure it is in the right place. The documentation lists several locations that are searched. Try putting it in one of the locations described:

  • the current working directory of the python process
  • at ~/.config/matplotlib/matplotlibrc

The latter actually did not work for me with debian 7, but neither does ~/.matplotlib/matplotlibrc.

share|improve this answer

matplotlib always uses its own set of fonts, independently of other fonts installed on the system. On Ubuntu 12.04 LTS, these fonts are located in /usr/share/matplotlib/mpl-data/fonts/.

When calling a font in your code which is not available in this directory, matplotlib will first try to fall back to Bitstream Vera Sans. However, neither that font is available in .../mpl-data/fonts/ on Ubuntu 12.04 LTS installations. Finally, matplotlib falls back to the cmb10.ttf font, which is available.

Installing system font packages as suggested above will not remedy this warning.

One can, however, add rcParams['mathtext.fontset'] = 'cm' to the code to avoid the multiple fallbacks and warnings.

Alternatively, specify a font which is present in /usr/share/matplotlib/mpl-data/fonts/.

share|improve this answer
Is there a way to add fonts to matplotlib? I tried soft-linking my ttf fonts to /usr/share/matplotlib/mpl-data/fonts/ttf/ with no success. –  PhilMacKay Oct 15 at 14:19

After some fiddling around with font packages, the solution for me was installing the following packages:

libsys-cpu-perl pcf2bdf tex-gyre ttf-bitstream-vera tv-fonts xfonts-traditional

I'm not sure why this helps, so perhaps somebody can add some background as to why this helps. Hopefully this helps someone else.

share|improve this answer
+1, same problem on ubuntu 12.10 (with mpl in a virtualenv). solved with your answer. thanks. –  bmu Oct 18 '12 at 14:15
It couldn't find the font. When you installed ttf-bitstream-vera, you installed the font that it wasn't finding. –  Timtro Jul 2 '13 at 14:27
@Timtro but then why does changing font.family not work? Or does it always try to resolve all font families when starting? –  Tim Aug 20 '13 at 10:16
@Tim - Good question. The answer was perfectly clear to me six weeks ago when I replied, but I can't see why at the moment. –  Timtro Aug 21 '13 at 14:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.