How to change the font of figures to be the "Times New Roman"?

2,023 views
Skip to first unread message

Ren

unread,
Oct 11, 2015, 9:43:43 AM10/11/15
to claw-users
Hi,
 
I just wonder how to change the font of figures to be the "Times New Roman". I have tried some methods.
But it does not work.  I think should modify setplot.py. I have added these words in setplot.py. But it do not make
the right things.
 

import matplotlib as mpl

mpl.rc('font',family='Times New Roman') 

 
 
Please give some advice. Many thanks.
Zhiyuan
 
 

Kyle Mandli

unread,
Oct 11, 2015, 3:19:43 PM10/11/15
to claw-...@googlegroups.com
You need to execute that before matplotlib.pyplot is imported. Beyond that your approach should work.
> --
> You received this message because you are subscribed to the Google Groups "claw-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to claw-users+...@googlegroups.com.
> To post to this group, send email to claw-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/claw-users.
> For more options, visit https://groups.google.com/d/optout.

Ren

unread,
Oct 12, 2015, 7:27:04 AM10/12/15
to claw-users
Hi, Kyle,
 
I have tried this method. But results mean it has been changed to be Bitstream Vera Sans with the following warning words, maybe cmb10.ttf of matplotlib. The results are shown in Fig.1.
 
/usr/lib/pymodules/python2.7/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['Times New Roman'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/usr/lib/pymodules/python2.7/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=15.0. Returning /usr/share/matplotlib/mpl-data/fonts/ttf/cmb10.ttf
  UserWarning)
/usr/lib/pymodules/python2.7/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=18.0. Returning /usr/share/matplotlib/mpl-data/fonts/ttf/cmb10.ttf
  UserWarning)
/usr/lib/pymodules/python2.7/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=20.0. Returning /usr/share/matplotlib/mpl-data/fonts/ttf/cmb10.ttf
  UserWarning)
/usr/lib/pymodules/python2.7/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=medium. Returning /usr/share/matplotlib/mpl-data/fonts/ttf/cmb10.ttf
  UserWarning)
 
 
 
Next, I have tried cmr10.ttf, while the results are shown in Fig.2. The font looks like Times New Roman. Maybe it is one of the solutions. However,
the minus sign can not show in the figure.
 
Hope for discussion.
Zhiyuan

在 2015年10月12日星期一 UTC+8上午3:19:43,Kyle Mandli写道:
1.png
2.png

Kyle Mandli

unread,
Oct 12, 2015, 10:01:48 AM10/12/15
to claw-...@googlegroups.com
Hi Zhiyuan,

As this appears to be a problem with your fonts and matplotlib I don’t think we are going to be much help to you. If you are still having problems I would look at the matplotlib mailing list for a solution.

Kyle
> <1.png><2.png>

Reply all
Reply to author
Forward
0 new messages