Add section about pgfplots

This commit is contained in:
Julius Freudenberger 2025-09-24 13:20:11 +02:00
parent 1163a6039a
commit 916e4fc27a
7 changed files with 124 additions and 0 deletions

View file

@ -15,6 +15,8 @@
\renewcommand{\glossarysection}[2][]{}
\usepackage{hyperref}
\usepackage{listings,minted}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.18}
\usepackage[duration=20]{pdfpc}
\usetheme{metropolis}
\author{Julius Freudenberger}
@ -397,6 +399,74 @@
\end{itemize}
\end{frame}
\section{Diagramme}
\begin{frame}[fragile]{Einbinden von pgfplots}
\begin{itemize}
\item Einbinden mit \verb|\usepackage|
\item Setzen der Version sehr empfohlen
\begin{itemize}
\item Garantiert gleiches Verhalten auch mit späteren Versionen von pgfplots
\item kann in neuen Dokumenten auf neue Version gesetzt werden (aktuell 1.18)
\end{itemize}
\end{itemize}
\inputminted{latex}{codebeispiele/pgfplots-setup.tex}
\end{frame}
\begin{frame}[fragile]{Diagramme mit pgfplots}
\begin{columns}
\begin{column}{.49\textwidth}
\input{codebeispiele/pgfplots.tex}
\end{column}
\begin{column}{.5\textwidth}
\inputminted{latex}{codebeispiele/pgfplots.tex}
\end{column}
\end{columns}
\end{frame}
\begin{frame}[fragile]{Syntax von pgfplots}
\begin{itemize}
\item Plot liegt immer in \verb|\tikzpicture| und \verb|axis|
\item Plot hinzufügen mit \verb|\addplot|
\item Plot endet mit \verb|;|
\item Achsen und Plots haben sehr viele Optionen, es gibt aber Defaults
\end{itemize}
\end{frame}
\begin{frame}{Plots aus Daten}
\only<1>{
\begin{columns}
\begin{column}{.3\textwidth}
\inputminted{text}{codebeispiele/pgfplots-data.dat}
\end{column}
\begin{column}{.6\textwidth}
\inputminted{latex}{codebeispiele/pgfplots-plot-data.tex}
\end{column}
\end{columns}
}
\only<2>{
\centering
\input{codebeispiele/pgfplots-plot-data.tex}
}
\end{frame}
\begin{frame}{Säulendiagramme}
\only<1>{
\begin{columns}
\begin{column}{.3\textwidth}
\inputminted{text}{codebeispiele/pgfplots-bars.dat}
\end{column}
\begin{column}{.6\textwidth}
\inputminted{latex}{codebeispiele/pgfplots-bar-chart.tex}
\end{column}
\end{columns}
}
\only<2>{
\centering
\input{codebeispiele/pgfplots-bar-chart.tex}
}
\end{frame}
\begin{frame}[fragile]{Bewerbungsunterlagen}
\begin{columns}
\column{.5\textwidth}

View file

@ -0,0 +1,13 @@
\begin{tikzpicture}
\begin{axis}[
title=Bar chart,
]
\addplot [
green,
fill=green!60!black,
ybar,
] table
{codebeispiele/pgfplots-bars.dat};
\legend{Quartalszahlen}
\end{axis}
\end{tikzpicture}

View file

@ -0,0 +1,6 @@
1 1
2 2
3 -3
4 0
5 3
6 4

View file

@ -0,0 +1,9 @@
-4 16
-3 9
-2 4
-1 1
0 0
1 1
2 4
3 9
4 16

View file

@ -0,0 +1,12 @@
\begin{tikzpicture}
\begin{axis}[
title=Import from table,
xlabel={$x$},
ylabel={$y$},
legend pos = outer north east,
]
\addplot [blue] table
{codebeispiele/pgfplots-data.dat};
\legend{$\approx x^2$}
\end{axis}
\end{tikzpicture}

View file

@ -0,0 +1,2 @@
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

View file

@ -0,0 +1,12 @@
\begin{tikzpicture}
\begin{axis}[
title={Beispieldiagramm},
xlabel={$x$-Achse},
ylabel={$y$-Achse},
]
\addplot[red,
domain=-5:5,
samples=100] { x^2 };
\legend{$x^2$}
\end{axis}
\end{tikzpicture}