爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 9836|回复: 3

[求助] 绘图保存汉字出错

[复制链接]

新浪微博达人勋

发表于 2014-6-15 16:48:17 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

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
有谁懂的???
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-6-17 08:44:03 | 显示全部楼层
汉字没怎么使用过,总是出错
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-9-2 10:17:34 | 显示全部楼层
        纬度   经度   强度   陡度  误差  定位方式  省   市   县
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-9-2 10:22:48 | 显示全部楼层
我还不会这个,下载下来研究一下
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表