Skip to main content

Embed matplotlib figures into LaTeX documents using PythonTeX

Project description

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.

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

pythontexfigures-0.2.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

pythontexfigures-0.2.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file pythontexfigures-0.2.0.tar.gz.

File metadata

  • Download URL: pythontexfigures-0.2.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pythontexfigures-0.2.0.tar.gz
Algorithm Hash digest
SHA256 99f2c9bff53ce5a41fa901add18328f0a767017949aee3198d58619c4fba9a4c
MD5 a02d97b1e62e832d4d0b7b7f42abaae2
BLAKE2b-256 aaf53dc9158c0cc74362281c8ff4e9fb24a39b5606e7726d2389c8101e857507

See more details on using hashes here.

File details

Details for the file pythontexfigures-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pythontexfigures-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for pythontexfigures-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56b978dcda84404252bafacb91336409bb28d4e746b786badfee575ab0802b16
MD5 14dd793c9103bfaecded61b79a174d68
BLAKE2b-256 20e8edb82dab41651ef6639b4ebc2c5a130864fc9065bb263e468d04dd086546

See more details on using hashes here.

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