苹果python怎么设置字体_在Mac OS X 10.6中的Python中,无法在Matplotlib中将字体更改为Helvetica...

我正在尝试将matplotlib字体更改为helvetica,我想在PDF图中使用.我尝试以下:

import matplotlib

matplotlib.use('PDF')

import matplotlib.pylab as plt

from matplotlib import rc

plt.rcParams['ps.useafm'] = True

rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})

plt.rcParams['pdf.fonttype'] = 42

这不行 – 当我使用–verbose-debug运行我的代码时,我得到错误:

backend WXAgg version 2.8.10.1

/Library/Frameworks/Python.framework/Versions/6.2/lib/python2.6/site-packages/matplotlib/__init__.py:833: UserWarning: This call to matplotlib.use() has no effect

because the the backend has already been chosen;

matplotlib.use() must be called *before* pylab, matplotlib.pyplot,

or matplotlib.backends is imported for the first time.

findfont: Could not match :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium. Returning /Library/Frameworks/Python.framework/Versions/6.2/lib/python2.6/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf

Assigning font /F1 = /Library/Frameworks/Python.framework/Versions/6.2/lib/python2.6/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf

Embedding font /Library/Frameworks/Python.framework/Versions/6.2/lib/python2.6/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf

Writing TrueType font

所以显然找不到Helvetica.我不知道为什么我的Helvetica在mpl数据的afm目录中,当matplotlib启动时,它读取并输出:

createFontDict: /Library/Frameworks/Python.framework/Versions/6.2/lib/python2.6/site-packages/matplotlib/mpl-data/fonts/afm/Helvetica.afm

另外需要一个特殊的.ttf Helvetica字体吗?如果是这样,我该怎么办?我知道我在我的系统中有Helvetica,因为我在Illustrator和许多其他程序中看到它.

我使用Enthought Python分发如下:

$python

Enthought Python Distribution -- http://www.enthought.com

Version: 6.2-2 (32-bit)

Python 2.6.5 |EPD 6.2-2 (32-bit)| (r265:79063, May 28 2010, 15:13:03)

[GCC 4.0.1 (Apple Inc. build 5488)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import matplotlib

>>> matplotlib.__version__

'0.99.3'

任何想法如何可以修复?

谢谢.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值