Skip to main content

A package to save matplotlib figures for easy inclusion in LaTeX.

Project description

MatpLaTeX

MatpLaTeX lets you save a matplotlib Figure as a combination of a pdf file containing the graphics and a LaTeX file containing the text. With this, text in the figure will automatically use the typeface, size and other settings of the surrounding text.

Installation

MatpLaTeX is on PyPI, simply

pip install matplatex

Python requirements:

  • python >= 3.10 (If someone asks I may add support for earlier versions.)
  • matplotlib >= 3.5
  • beartype

LaTeX requirements:

  • tikz
  • graphicx

Basic Usage

To save a figure, simply use

matplatex.save(fig, "myfig")

this will create two files named myfig.pdf and myfig.pdf_tex.

In your LaTeX document, define the width of the figure with

\newlength{\figurewidth}
\setlength{\figurewidth}{<your desired width>}

and include the figure as such:

\input{myfig.pdf_tex}

LaTeX commands such as \small and \textbf{} will affect the text in the expected way.

Options

Note: this is still under development and may change in future versions.

matplatex.save accepts the following keyword options:

  • widthcommand: string
    Command used to set the width of the figure. Default: \figurewidth.
  • draw_anchors: bool
    Mark the text anchors in the figure. Useful for debugging. Default: False.
  • verbose: bool
    Print message upon successful save. Default: True.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matplatex-0.4.5.tar.gz (20.2 kB view hashes)

Uploaded Source

Built Distribution

matplatex-0.4.5-py3-none-any.whl (20.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page