7

I am unable to avoid an error in matplotlib regarding font choice. Whenever I try to plot on a remote machine in Linux I get the following error:

/home/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/font_manager.py:1236:
UserWarning: findfont: Font family ['Arial'] not found. 
Falling back to Bitstream Vera Sans 
(prop.get_family(), self.defaultFamily[fontext]))

I have edited my .matplotlibrc file (just in case, in two locations):

  • .matplotlib/.matplotlibrc
  • .config/matplotlib/.matplotlibrc

Where I added the following lines:

backend: Agg
font.family        : serif
font.serif         : Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman
font.sans-serif    : Helvetica, Avant Garde, Computer Modern Sans serif
font.cursive       : Zapf Chancery
font.monospace     : Courier, Computer Modern Typewriter
text.usetex        : true

Still, matplotlib keeps complaining about Arial. Why? (note this is when running a script with python my_script.py) with no IPython involved.

1
  • Added the seaborn tag. If you are not using straight matplotlib you should indicate what extension layer you are using. Commented Apr 22, 2014 at 14:31

2 Answers 2

6

If you're using seaborn and don't have Arial installed, this will happen (I'm actually currently in the process of making this work better). Best solution for the time being would be to call

sns.set(font="serif")

After importing seaborn and before plotting.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks -- Has there been a solution since then? I recently upgraded seaborn from master with no success.
Unfortunately not, I ended up tracking the problem down to a bug in matplotlib. It should be fixed in 1.4...
What is sns? How would I set Arial if available on my system?
Seaborn is most commonly imported as sns.
3

from the documentation (see method description for set_family or set_name)

Real font names are not supported when text.usetex is True.

Perhaps you should use a font family like 'serif', 'sans-serif', 'cursive', 'fantasy', or 'monospace' if you'd like to be able to use TeX.

4 Comments

Thanks, although I am not sure I follow. Where am I failing to specify a font family like the ones you mentioned? What exactly do I need to change in my .matplotlibrc?
It would be helpful to see the code in which you are specifying 'Arial'.
I am not setting it myself. I wonder if this is coming from importing seaborn.
seaborn indeed overrides the fonts. @user815423426

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.