Ich würde mit <br>
`i. pgfplots` <br>
`ii. intersections` <br>
`iii. fillbetween` <br>
arbeiten.
**`Hinweis:`** Ich habe noch das `\ShowIntersection` Kommando verallgemeinert. Damit können nun beliebige Kurven mit oder ohne Schnittpunkte getestet werden.
werden: <br>
`\newcommand*{\ShowIntersection}[3][]{
\path[name intersections={of=#2 and #3, name=Schnitt, total=\t},
draw=red, fill=white, #1]
\ifnum\t>0 \foreach \s in {1,...,\t}{ (Schnitt-\s) circle (1.5pt) } \fi;
}`
**Beispiel aus Startpost:**
[![alt text][1]][1]
\documentclass[border=2pt, varwidth]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{intersections}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}[scale=1, font=\footnotesize,
declare function={
Kurve(\x) = sin(\x);
Waagrechte(\x) = 0.5;
},
]
\newcommand*{\ShowIntersection}[3][]{
\path[name intersections={of=#2 and #3, name=Schnitt, total=\t},
draw=red, fill=white, #1]
\ifnum\t>0 \foreach \s in {1,...,\t}{ (Schnitt-\s) circle (1.5pt) } \fi;
}
\begin{axis}[
trig format plots=rad,
axis lines = middle, unit vector ratio*=1 1 1,
%axis = equal,
axis line style = {-latex},
xmin=-0.25, xmax=3.5,
xtick={pi/2, pi},
xticklabels={$\frac{\pi}{2}$, $\pi$, },
extra x ticks = {0},
extra x tick labels= {$0$},
extra x tick style={tick label style={anchor=north east}
},
%
ytick={0,0.5,...,1},
%samples= 200,
ymin = -0.25, ymax=1.5,
%enlarge x limits={abs=0.5,upper},
%enlarge y limits={rel=0.5},
%
xlabel={$\delta$},
xlabel style={anchor=north},
ylabel={$y$},
ylabel style={anchor=east, inner sep=1pt},
]
\addplot[domain=0:pi, name path=kurve] {Kurve(x)};
\addplot[domain=0:pi, name path=waagrechte] {Waagrechte(x)};
\addplot[draw=none, name path=senkrechte] coordinates {(pi/2, 0) (pi/2, 1.5)};
\ShowIntersection{kurve}{waagrechte}
%\ShowIntersection[fill=red]{kurve}{senkrechte}
% Links füllen
\addplot fill between[of=senkrechte and kurve,
split,
every segment no 0/.style={fill=yellow, postaction={pattern=north west lines}},
every segment no 1/.style={fill=none},
];
\addplot fill between[of=waagrechte and kurve,
split,
every segment no 0/.style={fill=none},
every segment no 1/.style={fill=white},
every segment no 2/.style={fill=none}
];
% Rechts füllen
\addplot[domain=pi/2:pi, draw=none, name path=kurveR] {Kurve(x)};
\addplot[domain=pi/2:pi, draw=none, name path=waagrechteR] {Waagrechte(x)};
\addplot fill between[of=kurveR and waagrechteR,
split,
every segment no 0/.style={fill=blue!40, postaction={pattern=north east lines, solid}}, % "solid" unverständlicherweise nötig
every segment no 1/.style={fill=none},
];
\end{axis}
\end{tikzpicture}
\end{document}
[1]: https://texwelt.de/wissen/upfiles/55555555_318.png