该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#!/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 "", line 1, in
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
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
有谁懂的???