diff --git a/aufbaukurs.tex b/aufbaukurs.tex index 4126b52..753ab14 100644 --- a/aufbaukurs.tex +++ b/aufbaukurs.tex @@ -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} diff --git a/codebeispiele/pgfplots-bar-chart.tex b/codebeispiele/pgfplots-bar-chart.tex new file mode 100644 index 0000000..acdf9c9 --- /dev/null +++ b/codebeispiele/pgfplots-bar-chart.tex @@ -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} diff --git a/codebeispiele/pgfplots-bars.dat b/codebeispiele/pgfplots-bars.dat new file mode 100644 index 0000000..6b84c51 --- /dev/null +++ b/codebeispiele/pgfplots-bars.dat @@ -0,0 +1,6 @@ +1 1 +2 2 +3 -3 +4 0 +5 3 +6 4 diff --git a/codebeispiele/pgfplots-data.dat b/codebeispiele/pgfplots-data.dat new file mode 100644 index 0000000..d6ad47d --- /dev/null +++ b/codebeispiele/pgfplots-data.dat @@ -0,0 +1,9 @@ +-4 16 +-3 9 +-2 4 +-1 1 +0 0 +1 1 +2 4 +3 9 +4 16 diff --git a/codebeispiele/pgfplots-plot-data.tex b/codebeispiele/pgfplots-plot-data.tex new file mode 100644 index 0000000..9c7c475 --- /dev/null +++ b/codebeispiele/pgfplots-plot-data.tex @@ -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} diff --git a/codebeispiele/pgfplots-setup.tex b/codebeispiele/pgfplots-setup.tex new file mode 100644 index 0000000..8a8450a --- /dev/null +++ b/codebeispiele/pgfplots-setup.tex @@ -0,0 +1,2 @@ +\usepackage{pgfplots} +\pgfplotsset{compat=1.18} diff --git a/codebeispiele/pgfplots.tex b/codebeispiele/pgfplots.tex new file mode 100644 index 0000000..c628493 --- /dev/null +++ b/codebeispiele/pgfplots.tex @@ -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}