python 储存汉字_绘图保存汉字出错

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#!/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

有谁懂的???

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值