ich möchte mit pgfplots die Fläche zwischen zwei Funktionen einfärben und zwar je nachdem ob y1>y2 oder umgekehrt ist. Also z.B. eine rote Füllung wenn y1<y2 ist und eine grüne wenn y1>y2 ist.
Die Daten habe ich als Textdatei vorliegen. Ich habe ein lauffähiges Minimalbeispiel erarbeitet. Bisher ist es mir leider nur gelungen die Fläche zwischen den Plots mit nur einer Farbe zu füllen. Kann mir hier Jemand weiterhelfen?
\documentclass{standalone} \usepackage{pgfplots} \usepackage{filecontents} \begin{filecontents}{plotdata.dat} -3.5 0.350783228 -0.343633445 -3.25 0.108195135 -0.107984166 -3 -0.141120008 0.140652077 -2.75 -0.381660992 0.372462462 -2.5 -0.598472144 0.563380821 -2.25 -0.778073197 0.701908324 -2 -0.909297427 0.789072344 -1.75 -0.983985947 0.83271103 -1.5 -0.997494987 0.840114882 -1.25 -0.948984619 0.812824456 -1 -0.841470985 0.745624142 -0.75 -0.68163876 0.630066434 -0.5 -0.479425539 0.461269555 -0.25 -0.247403959 0.244887792 0 0 0 0.25 0.247403959 -0.244887792 0.5 0.479425539 -0.461269555 0.75 0.68163876 -0.630066434 1 0.841470985 -0.745624142 1.25 0.948984619 -0.812824456 1.5 0.997494987 -0.840114882 1.75 0.983985947 -0.83271103 2 0.909297427 -0.789072344 2.25 0.778073197 -0.701908324 2.5 0.598472144 -0.563380821 2.75 0.381660992 -0.372462462 3 0.141120008 -0.140652077 3.25 -0.108195135 0.107984166 3.5 -0.350783228 0.343633445 \end{filecontents} \begin{document} \begin{tikzpicture} \begin{axis} [] \addplot [] table[x index={0}, y index={1}] {plotdata.dat}; \addplot [] table[x index={0}, y index={2}] {plotdata.dat}; \addplot [draw=none,stack plots=y,forget plot] table [y index={1}] {plotdata.dat}; \addplot [draw=none, fill=gray, opacity=.5,stack plots=y] table [y expr=\thisrowno{2}-\thisrowno{1}] {plotdata.dat}\closedcycle; \end{axis} \end{tikzpicture} \end{document}