matplotlib2tikz, which creates a TikZ/pgfplots file that can be
\input in your document. I don't know how well it works, having never used
matplotlib, but I have used
matlab2tikz from the same author, and that works well. Also, I do not know if
matplotlib2tikz supports all the different kinds of plots that
matplotlib can create – in the Matlab case there are some limitations I believe.
For reference, here is a brief explanation of installation and use.
Having downloaded the files from github, navigate to the folder in a command line, and run
python setup.py install to install
In your Python script add
from matplotlib2tikz import matplotlib2tikz, and add
matplotlib2tikz('filename.tex') after your plot, e.g.
from numpy import arange
from matplotlib2tikz import matplotlib2tikz
import matplotlib.pyplot as plt
x = arange(0,10,0.5)
plt.title("A lovely plot")
You can also specify the width and height of the plot in the Python script, as mentioned in the readme of