How to use full path of font inside matplotlibrc - Arial not loading

I have Arial font installed in my system:

/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf

/usr/share/fonts/truetype/msttcorefonts/arialbi.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf

/usr/share/fonts/truetype/msttcorefonts/arial.ttf

/usr/share/fonts/truetype/msttcorefonts/ariali.ttf

/usr/share/fonts/truetype/msttcorefonts/arialbd.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial_Black.ttf

/usr/share/xbmc/media/Fonts/arial.ttf

/usr/local/share/texmf/fonts/tfm/urw/arial

/usr/local/share/texmf/fonts/afm/urw/arial

/usr/local/share/texmf/fonts/vf/urw/arial

/usr/local/share/texmf/fonts/type1/urw/arial

I have changed inside my matplotlibrc including the line:

font.sans-serif : Arial

If I check inside IPython:

import matplotlib.pyplot as plt

plt.plot([1,2,3,4,5,], ‘*’)

t = plt.ylabel(r’1, 2, 3, 8, 9 6 11 Testing Label’)

print(t.get_fontname())

The output is:

myhome/local/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-

x86_64.egg/matplotlib/font_manager.py:1279: UserWarning: findfont: Font

family [u’sans-serif’] not found. Falling back to Bitstream Vera Sans

(prop.get_family(), self.defaultFamily[fontext]))

Bitstream Vera Sans

How can I change this behavior and use Arial fonts for all of my plots?

Why Arial font is not loaded?

It is interesting, that if I use Seaborn, it returns Liberation Sans where the first font (inside internal font list) is Arial and the second is Liberation Sans.

I have also tried to set the full path of my Arial font:

import matplotlib as mpl

import matplotlib.pyplot as plt

import matplotlib.font_manager as font_manager

import seaborn as sns

path = ‘/usr/share/fonts/truetype/msttcorefonts/Arial.ttf’

prop = font_manager.FontProperties(fname=path)

mpl.rcParams[‘font.family’] = prop.get_name()

sns.set_style(“whitegrid”)

plt.plot([1,2,3,4,5,], ‘*’)

t = plt.ylabel(r’1, 2, 3, 8, 9 6 11 Testing Label’)

print(t.get_fontname())

It returns Liberation Sans. Any clues? (aka http://goo.gl/V511ux) =]

Cheers,

Arnaldo.

Even I have the same problem. The fonts are installed on my system, but matplotlib does not load them.

···

On Tue, Jan 20, 2015 at 10:57 PM, Arnaldo Russo <arnaldorusso@…287…> wrote:

I have Arial font installed in my system:

/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf

/usr/share/fonts/truetype/msttcorefonts/arialbi.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf

/usr/share/fonts/truetype/msttcorefonts/arial.ttf

/usr/share/fonts/truetype/msttcorefonts/ariali.ttf

/usr/share/fonts/truetype/msttcorefonts/arialbd.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial_Black.ttf

/usr/share/xbmc/media/Fonts/arial.ttf

/usr/local/share/texmf/fonts/tfm/urw/arial

/usr/local/share/texmf/fonts/afm/urw/arial

/usr/local/share/texmf/fonts/vf/urw/arial

/usr/local/share/texmf/fonts/type1/urw/arial

I have changed inside my matplotlibrc including the line:

font.sans-serif : Arial

If I check inside IPython:

import matplotlib.pyplot as plt

plt.plot([1,2,3,4,5,], ‘*’)

t = plt.ylabel(r’1, 2, 3, 8, 9 6 11 Testing Label’)

print(t.get_fontname())

The output is:

myhome/local/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-

x86_64.egg/matplotlib/font_manager.py:1279: UserWarning: findfont: Font

family [u’sans-serif’] not found. Falling back to Bitstream Vera Sans

(prop.get_family(), self.defaultFamily[fontext]))

Bitstream Vera Sans

How can I change this behavior and use Arial fonts for all of my plots?

Why Arial font is not loaded?

It is interesting, that if I use Seaborn, it returns Liberation Sans where the first font (inside internal font list) is Arial and the second is Liberation Sans.

I have also tried to set the full path of my Arial font:

import matplotlib as mpl

import matplotlib.pyplot as plt

import matplotlib.font_manager as font_manager

import seaborn as sns

path = ‘/usr/share/fonts/truetype/msttcorefonts/Arial.ttf’

prop = font_manager.FontProperties(fname=path)

mpl.rcParams[‘font.family’] = prop.get_name()

sns.set_style(“whitegrid”)

plt.plot([1,2,3,4,5,], ‘*’)

t = plt.ylabel(r’1, 2, 3, 8, 9 6 11 Testing Label’)

print(t.get_fontname())

It returns Liberation Sans. Any clues? (aka http://goo.gl/V511ux) =]

Cheers,

Arnaldo.


New Year. New Location. New Benefits. New Data Center in Ashburn, VA.

GigeNET is offering a free month of service with a new server in Ashburn.

Choose from 2 high performing configs, both with 100TB of bandwidth.

Higher redundancy.Lower latency.Increased capacity.Completely compliant.

http://p.sf.net/sfu/gigenet


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

You might need to delete the font cache (usually in ~/.matplotlib). Fonts installed after matplotlib is first used are often never recognized.

···

On Tue, Jan 20, 2015 at 3:50 PM, xkryptor <xkryptor@…287…> wrote:

Even I have the same problem. The fonts are installed on my system, but matplotlib does not load them.


New Year. New Location. New Benefits. New Data Center in Ashburn, VA.

GigeNET is offering a free month of service with a new server in Ashburn.

Choose from 2 high performing configs, both with 100TB of bandwidth.

Higher redundancy.Lower latency.Increased capacity.Completely compliant.

http://p.sf.net/sfu/gigenet


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

On Tue, Jan 20, 2015 at 10:57 PM, Arnaldo Russo <arnaldorusso@…287…> wrote:

I have Arial font installed in my system:

/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf

/usr/share/fonts/truetype/msttcorefonts/arialbi.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf

/usr/share/fonts/truetype/msttcorefonts/arial.ttf

/usr/share/fonts/truetype/msttcorefonts/ariali.ttf

/usr/share/fonts/truetype/msttcorefonts/arialbd.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf

/usr/share/fonts/truetype/msttcorefonts/Arial_Black.ttf

/usr/share/xbmc/media/Fonts/arial.ttf

/usr/local/share/texmf/fonts/tfm/urw/arial

/usr/local/share/texmf/fonts/afm/urw/arial

/usr/local/share/texmf/fonts/vf/urw/arial

/usr/local/share/texmf/fonts/type1/urw/arial

I have changed inside my matplotlibrc including the line:

font.sans-serif : Arial

If I check inside IPython:

import matplotlib.pyplot as plt

plt.plot([1,2,3,4,5,], ‘*’)

t = plt.ylabel(r’1, 2, 3, 8, 9 6 11 Testing Label’)

print(t.get_fontname())

The output is:

myhome/local/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-

x86_64.egg/matplotlib/font_manager.py:1279: UserWarning: findfont: Font

family [u’sans-serif’] not found. Falling back to Bitstream Vera Sans

(prop.get_family(), self.defaultFamily[fontext]))

Bitstream Vera Sans

How can I change this behavior and use Arial fonts for all of my plots?

Why Arial font is not loaded?

It is interesting, that if I use Seaborn, it returns Liberation Sans where the first font (inside internal font list) is Arial and the second is Liberation Sans.

I have also tried to set the full path of my Arial font:

import matplotlib as mpl

import matplotlib.pyplot as plt

import matplotlib.font_manager as font_manager

import seaborn as sns

path = ‘/usr/share/fonts/truetype/msttcorefonts/Arial.ttf’

prop = font_manager.FontProperties(fname=path)

mpl.rcParams[‘font.family’] = prop.get_name()

sns.set_style(“whitegrid”)

plt.plot([1,2,3,4,5,], ‘*’)

t = plt.ylabel(r’1, 2, 3, 8, 9 6 11 Testing Label’)

print(t.get_fontname())

It returns Liberation Sans. Any clues? (aka http://goo.gl/V511ux) =]

Cheers,

Arnaldo.


New Year. New Location. New Benefits. New Data Center in Ashburn, VA.

GigeNET is offering a free month of service with a new server in Ashburn.

Choose from 2 high performing configs, both with 100TB of bandwidth.

Higher redundancy.Lower latency.Increased capacity.Completely compliant.

http://p.sf.net/sfu/gigenet


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks Benjamin!!

In fact, this folder was inside .cache/matplotlib

I have removed the entire content, and know matplotlib seems to recognize Arial font.

Cheers,

Arnaldo