Darstellung der Frequenzbandbreite

Darstellung der Frequenzbandbreite

Ich habe fast keine Erfahrung damit pgfplotund habe einige Probleme mit etwas, das eigentlich einfach schien.

Ich möchte den Bereich zwischen einer Funktion und zwei vertikalen Linien füllen, die durch den Schnittpunkt einer horizontalen Linie mit der Funktion identifiziert werden.

Ich habe die Schnittpunkte gefunden und konnte die vertikalen Linien korrekt zeichnen, aber ich verstehe nicht, wie ich den Bereich füllen soll

Nachfolgend finden Sie den Code, den ich bisher erstellen konnte.

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc,intersections}






\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[scale=1]
\addplot+[name path global=GraphCurve, domain=0.5:1.5, samples=400, color=black, mark=none]{0.09*x^2/sqrt((1-x^2)^2+(0.09*x)^2)};

\addplot+[name path global=HorizontalLine, domain=0.5:1.5,mark=none, opacity=0]{0.5};

\path[dashed,name intersections={of=GraphCurve and HorizontalLine,name=i}] (i-2)%
      \pgfextra{\pgfgetlastxy{\macrox}{\macroy}%
         \global\let\macrox\macrox};
         \def \xinta {\macrox}
 \draw[name path global=vert1, dashed](i-2) -- (\xinta,0);        
 \path (i-1)
         \pgfextra{\pgfgetlastxy{\macrox}{\macroy}%
         \global\let\macrox\macrox};
              \def \xintb {\macrox} 

\draw[name path global=vert2,dashed](i-1) -- (\xintb,0);
\coordinate [label=left:$A$](A) at (i-1);
\coordinate [label=right:$B$](B) at (i-2);


\end{axis}
\end{tikzpicture}
\caption{This picture has been created with Pgfplots}
\end{figure}

\end{document}

Kann jemand dabei helfen?

Antwort1

Ich würde es ausschneiden.

Code

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usetikzlibrary{calc,intersections,backgrounds}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot+[name path global=GraphCurve, domain=0.5:1.5, samples=400, color=black, mark=none]{0.09*x^2/sqrt((1-x^2)^2+(0.09*x)^2)};

\addplot+[name path global=HorizontalLine, domain=0.5:1.5,mark=none, opacity=0]{0.5};

\path [name intersections={of=GraphCurve and HorizontalLine,name=i}];

\draw[dashed] (i-1) coordinate[label=left:$A$] -- ({axis cs:0,0} -| i-1);
\draw[dashed] (i-2) coordinate[label=right:$B$] -- ({axis cs:0,0} -| i-2);

\begin{scope}[on background layer]
    \clip ({axis cs:0,0} -| i-1) rectangle ({axis cs:0,\pgfkeysvalueof{/pgfplots/ymax}} -| i-2);
    \addplot+ [domain=0.5:1.5, samples=400, draw=none, mark=none, fill=gray] {0.09*x^2/sqrt((1-x^2)^2+(0.09*x)^2)} \closedcycle;
\end{scope}
\end{axis}
\end{tikzpicture}
\end{document}

Ausgabe

Bildbeschreibung hier eingeben

verwandte Informationen