title: Change Matplotlib's default font
body: <p>I'm trying to change matplotlib's default font to Helvetica Neue. On my Mac with EPD/Canopy everything worked fine some time ago. </p>
  
  <p>Trying to do the same on ubuntu now and it's not working. </p>
  
  <p>This is what I did:</p>
  
  <ol>
  <li><p>Installed Helvetica Neue </p>
  
  <pre><code>$ fc-match 'Helvetica Neue':Light
  HelveticaNeue-Light.otf: "Helvetica Neue" "細體"
  </code></pre></li>
  <li><p>Converted the odt/dfont into ttf:</p>
  
  <pre><code>fondu -show HelveticaNeue.dfont
  </code></pre></li>
  <li><p>changed matplotlibrc to </p>
  
  <pre><code>$ cat ~/.config/matplotlib/matplotlibrc
  ...
  font.family: Helvetica Neue
  </code></pre>
  
  <p>I also tried with:</p>
  
  <pre><code>font.family: sans-serif
  font.sans-serif: Helvetica Neue
  </code></pre></li>
  <li><p>I removed the font cache</p>
  
  <pre><code>rm ~/.config/matplotlib/fontList.cache
  </code></pre></li>
  </ol>
  
  <p>But none of these steps are working for me.</p>
  
  <pre><code>    $ python -c 'from  matplotlib import pyplot as plt; plt.plot(1); plt.savefig("/tmp/test.png")'
      /usr/local/lib/python2.7/dist-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/font_manager.py:1236: 
      UserWarning: findfont: Font family ['Helvetica Neue'] not found. Falling back to Bitstream Vera Sans
  </code></pre>
  
  <p>(prop.get_family(), self.defaultFamily[fontext]))</p>
  
  <p>Version is 1.3.0</p>
  
  <pre><code>    $ python -c 'import matplotlib; print  matplotlib.__version__'
      1.3.0
  </code></pre>
  
  <p>I also tried moving the fonts to <code>~/.config/matplotlib/fonts/ttf</code> but it didn't work. </p>
  
  <hr>
  
  <p><strong>EDIT:</strong>
  As suggested I tried selecting a specific font for a specific text. </p>
  
  <pre><code>import matplotlib as mpl
  mpl.use('Agg')
  import matplotlib.pyplot as plt
  import matplotlib.font_manager as font_manager
  
  path = '/home/&lt;myusername&gt;/.fonts/HelveticaNeue.ttf'
  
  prop = font_manager.FontProperties(fname=path)
  prop.set_weight = 'light'
  mpl.rcParams['font.family'] = prop.get_name()
  mpl.rcParams['font.weight'] = 'light'
  
  fig, ax = plt.subplots()
  ax.set_title('Text in a cool font', fontproperties=prop, size=40)
  plt.savefig('/tmp/test2.png')
  </code></pre>
  
  <p>But it makes no difference.</p>
  
  <pre><code>/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/font_manager.py:1236: 
  UserWarning: findfont: Font family ['Helvetica Neue'] not found. Falling back to Bitstream Vera Sans
  </code></pre>
  
  <p>However I seem to experience this problem only with this Helvetica/Helvetica Neue font.
        (prop.get_family(), self.defaultFamily[fontext]))</p>