diff options
author | Karl Berry <karl@freefriends.org> | 2022-03-11 22:03:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-03-11 22:03:59 +0000 |
commit | 594f56d8c6dd122d6841c134070753e69276d5cf (patch) | |
tree | 0741b22203b58b0b91e6aa87a4875f3ae7ff2acc /Master/texmf-dist/doc/lualatex/pyluatex/example/matplotlib-external.tex | |
parent | cc317986aedbee336d643590445a20b2d256b4f0 (diff) |
pyluatex (11mar22) (branch)
git-svn-id: svn://tug.org/texlive/branches/branch2021.final@62639 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/lualatex/pyluatex/example/matplotlib-external.tex')
-rw-r--r-- | Master/texmf-dist/doc/lualatex/pyluatex/example/matplotlib-external.tex | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/lualatex/pyluatex/example/matplotlib-external.tex b/Master/texmf-dist/doc/lualatex/pyluatex/example/matplotlib-external.tex new file mode 100644 index 00000000000..bdea9c0afd8 --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/pyluatex/example/matplotlib-external.tex @@ -0,0 +1,53 @@ +%% Copyright 2021-2022 Tobias Enderle +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. + +\documentclass{article} + +\usepackage{pyluatex} +\usepackage{graphicx} + +\title{PyLuaTeX Example -- Matplotlib External} +\author{Tobias Enderle} + +\begin{document} + +\maketitle + +In this document we demonstrate how \emph{matplotlib} plots can be generated and +included in a document. In the Python code in this document, the plot is +configured and saved to an external PDF file. This PDF file is then +included as picture using \verb|\includegraphics|. + +\begin{center} +\begin{python} +# example based on +# https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html +import matplotlib.pyplot as plt +import numpy as np + +t = np.arange(0.0, 2.0, 0.01) +s = 1 + np.sin(2 * np.pi * t) + +fig, ax = plt.subplots() +ax.plot(t, s) + +ax.set(xlabel='time (s)', ylabel='voltage (mV)', + title='About as simple as it gets, folks') +ax.grid() + +fig.savefig('matplotlib-plot.pdf', bbox_inches='tight', pad_inches=0.1) +\end{python} +\includegraphics[width=0.8\textwidth]{matplotlib-plot.pdf} +\end{center} + +For an alternative approach using the PGF backend, consider the example +\verb|matplotlib-pgf.tex|. + +\end{document} |