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.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56b978dcda84404252bafacb91336409bb28d4e746b786badfee575ab0802b16 |
|
MD5 | 14dd793c9103bfaecded61b79a174d68 |
|
BLAKE2b-256 | 20e8edb82dab41651ef6639b4ebc2c5a130864fc9065bb263e468d04dd086546 |