带有Python Rend中的乳胶文本的EMF图形

2024-03-28 19:59:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要使用python从数据中生成一些图形。它必须在标签、图例和标题中包含Latex文本,而输出格式必须是.emf(封装的图元文件,在M$Word中可读)。在

from pylab import *
from matplotlib import rc
import matplotlib.pyplot as plt
from sympy import pretty_print as pp, latex
import os
ion()

close('all')

rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
matplotlib.pyplot.rc('text', usetex=True)
matplotlib.rc('xtick',  labelsize = 12);
matplotlib.rc('ytick',  labelsize = 12);
matplotlib.rc('legend', fontsize  = 12);

A = loadtxt('Data.txt', unpack=True)

p1, = plot(A[0,:],A[1,:])

xlabel('time [s]', fontsize=14)
ylabel('Current i_1 [A]',fontsize=14)
title('Phase current',fontsize=14)
legend([p1],['i_1'], frameon=True, loc='upper right')
grid(True)
savefig('data.emf')

“EMF实例”没有错误。有人能解决这个问题吗?提前谢谢!在


Tags: 数据fromimporttruematplotlibasrclegend
1条回答
网友
1楼 · 发布于 2024-03-28 19:59:29

这是由于缺少matplotlib.textpath模块。您可以通过编辑文件[path to python libs]/matplotlib/backends/backend来解决这个问题_电动势. 在这个文件的头中添加一行

from matplotlib import textpath 

在renderemf类的类定义中添加行

^{pr2}$

初始化方法中。这修复了乳胶渲染至少对我来说。在

相关问题 更多 >