Ask Your Question
0

Sage unable to find font on my machine.

asked 2014-04-10 18:16:09 +0100

Shashank gravatar image

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"
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-04-10 19:00:35 +0100

Shashank gravatar image

Sorry for posting the question without googling enough.

The right way to set the font is

plt.rc('font', family = 'serif', serif = 'cmr10')
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-04-10 18:16:09 +0100

Seen: 918 times

Last updated: Apr 10 '14