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.9.11.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matplatex-0.9.11-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file matplatex-0.9.11.tar.gz.

File metadata

  • Download URL: matplatex-0.9.11.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.14.5 HTTPX/0.28.1

File hashes

Hashes for matplatex-0.9.11.tar.gz
Algorithm Hash digest
SHA256 fae593e57802fbbecfbfb9b93edc1a24dfca8b114c69899c6173b16369e3739c
MD5 064f7ba6659bf4434b755cb2f2258299
BLAKE2b-256 7357a87f73085de7c9f4e0ae745eb65145d92b1c8a8ab5526f10f0428fb35043

See more details on using hashes here.

File details

Details for the file matplatex-0.9.11-py3-none-any.whl.

File metadata

  • Download URL: matplatex-0.9.11-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.14.5 HTTPX/0.28.1

File hashes

Hashes for matplatex-0.9.11-py3-none-any.whl
Algorithm Hash digest
SHA256 c49596ae7685c3433a97810050fbd648b30417f18a54611f7c99c655f2e88012
MD5 e7e04e89eab72cfb06a95d3dfc550e3d
BLAKE2b-256 5f0161ed7c81545f6f124340c696764389344ffbd0dc8c877f756717c2e49318

See more details on using hashes here.

Supported by

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