Description
Problem
I would like to be able to export PGF files from matplotlib to be included in a Latex document, but without running into memory issues or exploding the compilation time.
Inkscape has an export feature that exports both a PDF file and a Latex file (.pdf_tex), where the text is rendered in Latex, and everything else is in a PDF file.
I've created a backend to do this using matplotlib: backend_pgftext.txt (for some reason .py files are not supported here...)
This renders everything but text into a PDF, places the text into a PGF file, then includes the PDF in the PGF file.
The advantage over a pure PDF file are:
- font rendering in Latex
- smaller file sizes due to lack of fonts in the PDF
The advantage over a pure PGF are:
- faster tex compilation (this is especially helpful for plots that have many data points).
- smaller file sizes
Disadvantages are that neither of the output files can be used alone to recreate the figure. Maybe there can be a PGF with the PDF data somehow embedded.
Would this be something that can be added to matplotlib if I submitted a pull request? I'm wondering if it will be useful to others.
Currently, I'm happy registering the backend locally to use it, but it may be nice to make it available in the official package.
Proposed solution
See the attached file: backend_pgftext.txt (it's a Python file, meant to go inside lib/matplotlib/backends/)