Fläche zwischen zwei Kurven füllen Thema ist als GELÖST markiert

Tabellen und Grafiken erstellen und anordnen


axu

Fläche zwischen zwei Kurven füllen

Beitrag von axu »

Hallo,

ich würde gerne die Fläche zwischen zwei Kurven füllen. Leider klappt das bei mir nicht.

Hier mal das Minimalbesipiel
\documentclass[a4paper]{article}

\begin{filecontents}{Data.csv}
eins;zwei;drei;vier;fuenf;sechs
0.000;0.000;0.000;0.000;0.000;0.000
-0.002;0.014;0.147;-0.600;55.961;11.413
-0.004;0.022;0.165;-0.598;50.177;10.872
-0.010;0.092;0.200;-0.592;46.976;9.818
-0.012;0.110;0.208;-0.590;45.910;9.447
-0.014;0.124;0.236;-0.588;44.846;9.250
-0.020;0.151;0.295;-0.582;41.666;8.689
\end{filecontents}

\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
	
	\begin{tikzpicture}
    	\begin{axis}
	\addplot
	  table[name path=A, mark=none,x expr=\thisrowno{0}, y expr=(\thisrowno{1}-\thisrowno{2})*-1, header=true, col sep=semicolon] {data.csv};
	\addplot
   	  table[name path=B, mark=none,x expr=\thisrowno{0}, y expr=(\thisrowno{1}+\thisrowno{2})*-1, header=true, col sep=semicolon] {data.csv};
     \addplot[blue!50] fill between[of=A and B];
    	\end{axis}
	\end{tikzpicture}
\end{document}
LaTeX bricht mit einigen Fehler ab. Wenn die Zeile mit "fill between" auskommentiert ist, werden zumindest die Graphen richtig geplottet.

Über eine Hilfestellung wäre ich sehr dankbar.

Bartman
Forum-Meister
Forum-Meister
Beiträge: 2466
Registriert: Do 16. Jul 2009, 21:41
Wohnort: Hessische Provinz

Beitrag von Bartman »

\documentclass[border=5pt]{standalone}

\begin{filecontents}{Data.csv}
eins;zwei;drei;vier;fuenf;sechs
0.000;0.000;0.000;0.000;0.000;0.000
-0.002;0.014;0.147;-0.600;55.961;11.413
-0.004;0.022;0.165;-0.598;50.177;10.872
-0.010;0.092;0.200;-0.592;46.976;9.818
-0.012;0.110;0.208;-0.590;45.910;9.447
-0.014;0.124;0.236;-0.588;44.846;9.250
-0.020;0.151;0.295;-0.582;41.666;8.689
\end{filecontents}

\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}

\pgfplotsset{compat=newest}% für den Online-Editor, bei aktueller Version von pgfplots 1.14

\begin{document}
\begin{tikzpicture}
\begin{axis}[
	no markers,
	table/col sep=semicolon,
	table/x expr=\thisrowno{0}
]
\addplot[name path=A] table[
   y expr=(\thisrowno{1}-\thisrowno{2})*-1
] {Data.csv};
\addplot[name path=B] table[
   y expr=(\thisrowno{1}+\thisrowno{2})*-1
] {Data.csv};
\addplot[blue!50] fill between[of=A and B];
\end{axis}
\end{tikzpicture}
\end{document}
Zuletzt geändert von Bartman am Di 15. Nov 2016, 14:47, insgesamt 1-mal geändert.

axu

Beitrag von axu »

Keiner Fehler, große Wirkung...

Vielen Dank!

Antworten