Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[ENH]: PGF Backend for Text only (rest of plot in included PDF) #22297

Copy link
Copy link
Open
@alspitz

Description

@alspitz
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.