From 4048ff88283ed4bde8d03e15b0903fc6f3653e47 Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Wed, 28 Feb 2018 09:25:22 -0500 Subject: [PATCH] Add example for plotting values read from csv files with pgfplots --- data/data.csv | 6 ++++++ latexhints-english.tex | 13 +++++++++++++ latexhints-german.tex | 13 +++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 data/data.csv diff --git a/data/data.csv b/data/data.csv new file mode 100644 index 00000000..5da6fb96 --- /dev/null +++ b/data/data.csv @@ -0,0 +1,6 @@ +a,b,c,d +1,4,5,1 +2,3,1,5 +3,5,6,1 +4,1,4,9 +5,3,4,7 \ No newline at end of file diff --git a/latexhints-english.tex b/latexhints-english.tex index 2aa28622..b9d603ca 100644 --- a/latexhints-english.tex +++ b/latexhints-english.tex @@ -370,6 +370,19 @@ \section{Weitere Illustrationen} \end{center} \caption{Plot of $\sin(x)$ direclty inside the figure environment with pgfplots.} \end{figure} + + \begin{figure}[h] + \begin{center} + \begin{tikzpicture} + \begin{axis}[xlabel=$x$, + ylabel=$y$] + \addplot table [x=a, y=c, col sep=comma] {data/data.csv}; % Read coordinates from csv file and plot them + \end{axis} + \end{tikzpicture} + \end{center} + \caption{Coordinates $x$ and $y$ read from csv file and plotted pgfplots.} + \end{figure} + }{} \IfFileExists{tikz.sty}{ diff --git a/latexhints-german.tex b/latexhints-german.tex index fb068e14..e75ce700 100644 --- a/latexhints-german.tex +++ b/latexhints-german.tex @@ -406,6 +406,19 @@ \section{Weitere Illustrationen} \end{center} \caption{$\sin(x)$ mit pgfplots.} \end{figure} + + \begin{figure}[h] + \begin{center} + \begin{tikzpicture} + \begin{axis}[xlabel=$x$, + ylabel=$y$] + \addplot table [x=a, y=c, col sep=comma] {data/data.csv}; % Koordinaten aus einer CSV-Datei lesen und plotten + \end{axis} + \end{tikzpicture} + \end{center} + \caption{Koordianten $x$ und $y$ aus einer CSV-Datei geplottet mit pgfplots.} + \end{figure} + }{} \IfFileExists{tikz.sty}{