0
votes

noob here. I can't figure out the correct matplotlib line to use my newly loaded gillius font.

So I installed gillius font of the arkandis digital foundry on my machine ttf-adf-gillius

here is the place i "think" it put it

usr/share/fonts/truetype/adf/GilliusADF-Regular.otf: Gillius

ADF:style=Regular

SO if I want to use it in my Python 3.4 program that imports matplotlib. I set the font_family= 'Gillius" and the program doesn't find it. What do I set the font family to to use my font please?

here is an example message from my python program

Warning (from warnings module): File "/usr/lib/python3/dist-packages/matplotlib/font_manager.py", line 1279

(prop.get_family(), self.defaultFamily[fontext])) UserWarning: findfont: Font family ['Gillius'] not found. Falling back to Bitstream Vera Sans

Warning (from warnings module): File "/usr/lib/python3/dist-packages/matplotlib/font_manager.py", line 1289

UserWarning) UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=20.0. Returning /usr/share/matplotlib/mpl-data/fonts/ttf/cmmi10.ttf

I had already tried using the suggested link How to use a (random) *.otf or *.ttf font in matplotlib?

but it didn't seem to do anything. My question is assuming the font is installed correctly what is the font family I should be entering to have matplotlib use it?

1
Hey Tom thank you for replying BUT I mentioned that in my question and said it didn't work. thanks anywaytheakson
This might be helpful...Primer
Hey Primer spot on and thank you for finding it. I am a little embarrassed I didn't despite my searching. I'm finding the transition to linux and learning Python to be a little soul destroying. So many things have to be tweeked but I suppose that goes with the territory.theakson

1 Answers

0
votes

Ok I "think" this is a way to do it based on all the GREAT help I got on SO. thanks to all. I am new to matplotlib so if I screwed up happy to correct it.

import matplotlib
import matplotlib.font_manager as fm
from matplotlib import pyplot as plt


font = fm.FontProperties(
       family = 'Gill Sans',
       fname = '/usr/share/fonts/truetype/adf/GilliusADF-Regular.otf')

data = range(5)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.bar(data, data)
plt.ylabel('some y numbers')
plt.xlabel('some x numbers')
ax.set_yticklabels(ax.get_yticks(), fontproperties = font)
ax.set_xticklabels(ax.get_xticks(), fontproperties = font)
ax.set_title('this is a test of Gill sans font')
plt.show()