Tell me more ×
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.plot(np.random.random((128)))
plt.title("This should be monospaced")
plt.savefig("/tmp/testfig.pdf")

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

1 Answer

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

Your Answer

 
discard

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.