semvec/pypi-packages huggingface dataset:
pythontexfigures 0.2.0
Embed matplotlib figures into LaTeX documents using PythonTeX
License: BSD 3-Clause
Requires Python: >=3.5

# LaTeX Python figures



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

```python

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:



```latex

\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:

```bash

pip3 install pythontexfigures

```



To install the LaTeX package into `texmf-local`:

```bash

sudo python3 -m pythontexfigures.install

```

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

```bash

sudo python3 -m pythontexfigures.install TEXMFHOME

```



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