I need to produce some figures from data, using python. It has to have Latex text in labels, legend and title, while output format must be .emf (Encapsulated Metafile, readable in 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')
Errors are like this: "RendererEMF instance has no attribute". Does anyone have a solution for this problem? Thanks in advance!
This is due to a missing link between the matplotlib.textpath module. You can solve this by editing the file [path to python libs]/matplotlib/backends/backend_emf.py. In the header of this file add the line
In the class definition of the class RendererEMF add the line
in the init method. This fixed latex rendering in emf at least for me.