Tony,

Thanks for your answer.  I'm running on CentOS Linux.  Unfortunately
there is no such command as font_manager.X11InstalledFonts(), though
there is font_manager.x11FontDirectory().  When I do that I get a list
with a bunch of directories including '/usr/share/msttcorefonts', which
contains the times.ttf which has the Times New Roman font I wanted.  And
by doing things like:
fprop = font_manager.FontProperties(fname=
        '/usr/share/fonts/msttcorefonts/times.ttf')
set_xlabel('X title',fontproperties=fprop)
xticklabels = plt.getp(plt.gca(), 'xticklabels')
plt.setp(xticklabels, fontproperties=fprop)

I can get the fonts I want for xlabel, ylabel, etc., but I still can't
get that font set as the default font (using, for example 'times' for
the value for serif, or for family).  For some reason setting the
rcParam doesn't work.  In the context in which it's invoked to find the
font, the font manager can't find it.  So far I haven't been able to
track down the problem.

Jon

On Fri, 2011-12-02 at 17:30 -0500, Tony Yu wrote:
> On Fri, Dec 2, 2011 at 4:13 PM, Jonathan Slavin
> <jsla...@cfa.harvard.edu> wrote:
>         Hi all,
>         
>         I've been trying to use a different serif font for a plot and
>         have been
>         running into problems.  I thought I could just do something
>         like:
>         
>         from matplotlib import rc
>         rc('font', family='serif', serif='Times New Roman')
>         
>         but if I try that I end up getting:
>         findfont: Font family ['serif'] not found. Falling back to
>         Bitstream
>         Vera Sans
>         
>         It works fine without the serif='...' part and gives me the
>         default
>         serif font.  I know that Times New Roman exists on my system
>         -- at least
>         the GNOME character map can find it.  Perhaps I need to use a
>         different
>         alias (but what would it be?).  Any help would appreciated.
>         
>         Jon
> 
> 
> You should check what fonts are installed on your system:
> 
> >>> from matplotlib import font_manager
> >>> font_manager.OSXInstalledFonts()
> 
> (or if you're on a different system, try MSInstalledFonts or
> X11InstalledFonts---those aren't available on my system, but
> presumably that's just because I'm using OSX). If that works, then
> look for Times New Roman in what's printed out. If it is, the problem
> may be that it's not the right format: it appears as if the
> font_manager only supports .ttf and .afm fonts.
> 
> If you don't see Times New Roman in any of those files, check the
> output of
> 
> >>> mpl.font_manager.OSXFontDirectories
> 
> (replacing OSX with MS or X11, if needed). If the listed directories
> doesn't match your installation of Times New Roman, that's your
> problem. (I'm not sure if there's a good way of adding directories.)
> 
> Cheers,
> -Tony
> 



------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to