EMF figures with latex text from Python - Renderer error

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


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')

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

from matplotlib import textpath 

In the class definition of the class RendererEMF add the line

self._text2path = textpath.TextToPath() 

in the init method. This fixed latex rendering in emf at least for me.

Need Your Help

Javascript replace portion of innerHTML for template engine

javascript html html5 dom

I am writing a template engine. I am trying to update certain parts of the innerHTML on demand, for instance when the model updates.

Is there a way to loop through a sub section of a list in Python

python loops list

So for a list that has 1000 elements, I want to loop from 400 to 500. How do you do it?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.