Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Sage unable to find font on my machine.

I was trying to change the font on a plot to Computer Modern Roman. Is there a way I can install the fonts in sage itself so that sage does not have to look all over the disk for the right font. Here is the code for the plot

from matplotlib import rc, rcParams
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

#plt.rc('text', usetex=True)
plt.rc('font',**{'family':'serif','serif':['Computer Modern Roman'],'size':12})
fig = plt.figure(figsize=(4.0,2.8))
ax = fig.add_subplot(111)
plt.ylim(0,20)
plt.xlim(0,20)
a=[0,10,20]
b=[0,10,20]
p1=plt.plot(a, b,'r--')
plt.savefig('test.png')

I get the message

"/Users/shashank/sage/local/lib/python2.7/site-packages/matplotlib/font_manager.py:1224: UserWarning: findfont: Font family ['serif'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))".

Has anyone else encountered this issue and how does one fix it. I am using a Mac if that helps.

Also uncommenting usetex=true leads to the following error, I have installed the latest version of freetype from port on mac.

dyld: Library not loaded: /opt/local/lib/libfreetype.6.dylib
  Referenced from: /opt/local/lib/libpoppler.44.dylib
  Reason: Incompatible library version: libpoppler.44.dylib requires version 18.0.0 or later, but libfreetype.6.dylib provides version 10.0.0
sh: line 1:  2899 Trace/BPT trap: 5       latex -interaction=nonstopmode 342a49751566a29dab1cfcec0a04bf79.tex > "/Users/shashank/.sage//matplotlib-1.2.1/tex.cache/342a49751566a29dab1cfcec0a04bf79.output"