Skip to main content

LaTeX Python figures

Given a Python script like this which draws a Matplotlib figure:

def main():

    x = np.arange(10)

    y = x**2

    plt.plot(x, y)

    plt.xlabel('$x$')

    plt.ylabel('$x^2$')

    return 'test'  # Figure filename

you can insert it into a LaTeX document like this:

\begin{figure}

    \pyfig{'test.py'}

    \caption{Test figure.}

\end{figure}

By default, the figure size defaults to \textwidth square and the font and font size match the rest of the document.

Installation

Requires a LaTeX installation (probably TeX Live 2019), PythonTeX, and Python 3.6 or greater.

Examples require latexmk.

To install the Python package:

pip3 install pythontexfigures

To install the LaTeX package into texmf-local:

sudo python3 -m pythontexfigures.install

If you don't have root access, you can install it into texmf-home instead:

sudo python3 -m pythontexfigures.install TEXMFHOME

Alternatively, call pf.print_preamble() in your pythontexcustomcode and follow with \printpythontex.

Metadata

Release files for pythontexfigures 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pythontexfigures 0.2.0
File Size Uploaded
pythontexfigures-0.2.0.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pythontexfigures 0.2.0
File Interpreter ABI Platform
pythontexfigures-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.7 kB

Release files / pythontexfigures-0.2.0.tar.gz

Download URL pythontexfigures-0.2.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
99f2c9bff53ce5a41fa901add18328f0a767017949aee3198d58619c4fba9a4c
BLAKE2b-256 checksum
How to use checksums
aaf53dc9158c0cc74362281c8ff4e9fb24a39b5606e7726d2389c8101e857507
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / pythontexfigures-0.2.0-py3-none-any.whl

Download URL pythontexfigures-0.2.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56b978dcda84404252bafacb91336409bb28d4e746b786badfee575ab0802b16
BLAKE2b-256 checksum
How to use checksums
20e8edb82dab41651ef6639b4ebc2c5a130864fc9065bb263e468d04dd086546
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page