Original report at SourceForge, opened Thu Aug 20 12:42:48 2009
It would be nice to render plots directly to TikZ for embedding as native graphics in (La/Con)TeX(t). There are random, small projects across the web that I've found that offer provisional translation from EPS or SVG to TikZ, but nothing really complete. In fact, given a simple test case
that matplotlib rendered in SVG or EPS, each one failed in one way or another. The most promising seems to be an inkscape plugin,
but I'd rather have something that I can script, or better yet, have matplotlib output plots directly into TikZ code.
I've started a matplotlib2tikz converter some time ago at GitHub, as a proper backend is not really suitable for the task: Backends only have access to basic information like "draw a line from a to b" instead of "draw x-tick at 0.4", which is what TikZ/Pgfplots needs. Anyway, most of this stuff can really be fetched from all those get_* methods.
I've been working this morning on it a bit, and right now the converter should be in okay shape for simple plots, some colored graphs with labels, legends, this kind of stuff.
Just poke me on GitHub or so if you're still motivated. :)
The Github repository mentioned in this bug appears to have moved to:
I will check-in with the author over there.
There is https://github.com/pwuertz/matplotlib-backend-pgf/
This might resolve this issue.
The pgf backend should indeed resolve the issue, except if you expected the output to be human readable or editable.
This is probably what matplotlib2tikz is supposed to do, but as Nico said, this cannot be realized as a backend. Also, since matplotlib2tikz must interpret and recreate the whole figure from matplotlib it will never exactly reproduce the result you'll see with a backend, which is why I started the pgf-backend.