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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pythontexfigures-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6fd17a786b8b2b3714cd2d2007e65a3646785d0ba8d42995e58892640f077fd |
|
MD5 | 43c61a59f42f03a8657a3b7f706514e4 |
|
BLAKE2b-256 | 43e976eaaec9cd6c2544d02d923e3949bdfc12bbb7c44e4d1d053532bd61b4ed |