Ask Your Question
0

Font warning when using matplotlib semilogy after upgrade from F19 to F20

asked 2014-01-08 03:56:01 -0500

mdriu gravatar image

updated 2014-09-28 17:44:00 -0500

mether gravatar image

I have been using the semilogy matplotlib.pyploy function for a while without any problem in Fedora 19. Recently, I updated to Fedora 20 using fedup, having no update issues at all.

After the update, my python scripts that contain the semilogy function are giving the following font warning, and result in a very "slow" plot window ("slow" resize, "slow" zoom, "slow" pan). Linear axis plot functions (e.g. plot) work fine and result in smart plot windows.

The following code in the example.py file reproduces the warnings for me:

"""
Simple example of matplotlib plot
"""

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

def simple_ex():
    print 'numpy version = ', np.__version__
    print 'matplotlib version = ', mpl.__version__
    x = np.linspace(0, 5, 1000)
    y1 = np.sinc(x)
    y2 = np.sinc(2*x)
    plt.semilogy(x, y1, label='Sinc1')
    plt.semilogy(x, y2, label='Sinc2')
    x1, x2 = plt.axis()[:2]
    plt.axis((x1, x2, 1e-2, 1))
    plt.grid()
    plt.legend()
    plt.xlabel('x')
    plt.ylabel('f(x)')
    plt.show()

if __name__ == "__main__":
    simple_ex()

and the result I get is:

$ python example.py 
numpy version =  1.8.0
matplotlib.pyplot version =  1.3.0
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['STIXGeneral'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=12. Returning /usr/share/fonts/gnu-free/FreeSansOblique.ttf
  UserWarning)
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['STIXSizeOneSym'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=bold:stretch=normal:size=12. Returning /usr/share/fonts/gnu-free/FreeSansOblique.ttf
  UserWarning)
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['STIXSizeThreeSym'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['STIXSizeFourSym'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['STIXSizeFiveSym'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['STIXSizeTwoSym'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=italic:variant=normal:weight=normal:stretch=normal:size=12. Returning /usr/share/fonts/gnu-free/FreeSansOblique.ttf
  UserWarning)
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['STIXNonUnicode'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/usr/lib64/python2.7/site-packages/matplotlib/font_manager ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-01-08 20:39:51 -0500

hmaarrfk gravatar image

updated 2014-01-08 20:43:50 -0500

It seems that matplotlib is missing some dependencies for latex fonts.

cmb10 is a latex font. Try installing some latex-fonts.

If you installed matplotlib using pip, then remove it using pip, install it via yum, then remove it via yum (it should keep the dependencies), then install it via pip again.

----- Previous (invalid) answer ----------

Personally, I would not install packages for python via yum. Yum does help resolve dependencies but the packages are sometimes out of date.

Try removing matlplotlib using yum then reinstalling it using

sudo yum pip install matplotlib[all]

FYI You are missing in your code

import matplotlib as mpl
edit flag offensive delete link more

Comments

Thank you, I corrected the code. I will try your solution and let you know.

mdriu gravatar imagemdriu ( 2014-01-09 01:58:03 -0500 )edit

I found a discussion here http://matplotlib.1069221.n5.nabble.com/stix-fonts-not-found-fedora-20-td42656.html where they suggest the same fix as you, and also give an explanation. However, I am not enthusiastic about installing modules outside yum.

mdriu gravatar imagemdriu ( 2014-01-09 03:46:49 -0500 )edit

Honestly, in this case it is probably better to install the python modules outside of yum because they will stay more up to date. Actually, the best practice would be to set up a virtual environment for python and use pip to install modules there

hmaarrfk gravatar imagehmaarrfk ( 2014-01-09 21:35:32 -0500 )edit

Question Tools

Stats

Asked: 2014-01-08 03:56:01 -0500

Seen: 1,691 times

Last updated: Jan 09 '14