- 积分
- 2
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-5-24
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
#!/usr/bin/python
# -*- coding:utf-8 -*-
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r'D:\simsun.ttc', size=24)
path=r'E:\Research\Vow Folder\Art\Art-3\Graph\2014-04-22\pic3-Joint'
pp=PdfPages(path+'\\pic.pdf')
fig = plt.figure()
x=np.arange(10)
y=x
plt.plot(x,y)
plt.title(u'测试',fontproperties=font)
pp.savefig(fig)
pp.close()
plt.show()
画图后有字显示,可是为什么保存为pdf的时候报错呢?
>>> runfile('E:/python/CaseBase/Test/test2.py', wdir=r'E:/python/CaseBase/Test')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile
execfile(filename, namespace)
File "E:/python/CaseBase/Test/test2.py", line 20, in <module>
pp.close()
File "D:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line 2286, in close
self._file.close()
File "D:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line 507, in close
self.writeFonts()
File "D:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line 607, in writeFonts
fonts[Fx] = self.embedTTF(realpath, chars[1])
File "D:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line 1053, in embedTTF
return embedTTFType3(font, characters, descriptor)
File "D:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line 844, in embedTTFType3
rawcharprocs = ttconv.get_pdf_charprocs(filename, glyph_ids)
RuntimeError: TrueType font is missing table
>>> Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "D:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 254, in qt_inputhook
QtCore.QCoreApplication.exec_()
KeyboardInterrupt
有谁懂的??? |
|