From: per f. <per...@gm...> - 2009-08-22 23:36:19
|
i figured out what i did wrong and so am writing it here in case it helps others. the basic issue is that the .ttf font was missing in the new matplotlib directory. to discover this, i ran python with --verbose-debug as suggested in previous threads by others. then i copied my version of Helvetica.ttf into: /Library/Python/2.5/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts and /Library/Python/2.5/site-packages/matplotlib/mpl-data/fonts/ttf then everything worked and i was able to change fonts to helvetica. thanks. On Sat, Aug 22, 2009 at 7:12 PM, per freem<per...@gm...> wrote: > Hi all, > > the following code used to work for me in matplotlib-0.98 to make a > simple scatter plot and change the font from the default font to > Helvetica (I am using mac os x). > > import matplotlib > matplotlib.use('PDF') > import matplotlib.pyplot as plt > from matplotlib import rc > rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']}) > from scipy import * > from numpy import * > > my_fig = plt.figure(figsize=(6,5), dpi=100) > x = rand(100)*300 > y = rand(100) > plt.scatter(x, y) > plt.rcParams['xtick.direction'] = 'out' > plt.rcParams['ytick.direction'] = 'out' > c = 0.05*300.5 > plt.xlim([0-c, 300+c]) > plt.ylim([-0.05, 1.05]) > plt.savefig('x.pdf') > > i recently upgraded to matplotlib-0.99 and the changing of the font > using the above method no longer works. the figure is plotted the > same, but the font remains the default matplotlib font. > > one potential problem in the installation was this: i installed > matplotlib-0.99 using the dmg prepackaged binary installer. this > installed matplotlib in the directory: > > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages > > however, for some reason ipython / python2.5 was looking for packages in: > > /Library/Python/2.5/site-packages > > and so matplotlib/mpl_toolkits was not found. so I copied the > directories 'matplotlib' and 'mpl_toolkits' from > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages > to /Library/Python/2.5/site-packages. Perhaps this was the cause of > the problem? > > thanks for your help. > > (i run my code via ipython, by the way.) > |