Reputation: 59
I am trying to use Computer Modern (i.e. the standard LaTeX font) in my pyplot figures, however, I get the error
findfont: Font family ['serif'] not found. Falling back to DejaVu Sans.
All I do is:
from matplotlib import rc
rc('text', usetex=True)
rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})
I have also found this thread which dealt with the same issue, however, I cannot install the packages mentioned in the answer there because I am not an admin on the machine I am using. Deleting the matplotlib cache did not help, either. I have located the font, though:
~/.local/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/
which has the subfolders afm and ttf (and another one), and within both of them, I find files like
cmr10.afm
or
cmr10.ttf
so the fonts are actually installed on the computer. The fontlist-v330.json file links to
"fname": "fonts/afm/cmr10.afm"
for Computer Modern. I have tried manually changing this to the ttf file, and I have also tried giving it the full path, but to no avail. At this point, I am at a loss for ideas. How can I solve this issue?
Upvotes: 0
Views: 3143
Reputation: 2058
All you need to do should be using the actual name of the font file:
from matplotlib import rc
rc('text', usetex=True)
rc('font', **{'family': 'serif', 'serif': ['cmr10']})
Upvotes: 2