Einen Teil eines Bilds ausblenden

Einen Teil eines Bilds ausblenden

Ich habe diesen Code (angepasst vonpgfplot: Zwischenraum auffüllen und gleichzeitig Dekorationsfunktion einbinden):

%https://tex.stackexchange.com/questions/671424/pgfplot-fill-between-while-including-decoration-function
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{decorations.markings}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            axis lines=center,
            xmin=0, xmax=12.5,
            ymin=0, ymax=15,
            ]
            \fill[blue!60] (7,7.8)--(8.3,7.8)--(7,9.5)--cycle;
            \draw[violet,line width=3pt] (7,7.5)--(7,10);
            \filldraw[brown!40,draw=blue,line width=2pt] (6,6.5)--(5.5,7.5)--(8.5,7.5)--(8,6.5)--cycle; 
            \node at (6.3,7.2) () {\tiny \LaTeX};
            \draw[name path=line] (0,0) -- (12,0);
            \addplot[
            name path=plot, 
            cyan,
            domain=0:12,
            preaction={decorate},
            samples=100,
        %   decoration={markings, mark=between positions 0.05 and 1 step (1/12)*\pgfdecoratedpathlength with {\arrow{latex}}}, % commenta questa linea se non vuoi le frecce                   
            ] {.1*sin(3*x*180/pi)+7};
            \addplot[fill=cyan!40] fill between[of=line and plot,overlay];
        \end{axis}    
    \end{tikzpicture}
\end{document}

die diese Ausgabe erzeugen:

Bildbeschreibung hier eingeben

Ich möchte den Teil des Bootes unter Wasser verstecken. Ich habe es mit opaque, opacity=,... versucht, aber ohne das gewünschte Ergebnis.

Antwort1

Wie bereits erwähnt indiese Frage und Antwortmüssen Sie die Ebene für mit dem fill betweenOperator gezeichnete Dinge festlegen.

DerHandbuch erklärt dass mit dem Operator gezeichnete Dinge fill betweenstandardmäßig auf einer Ebene platziert werden, die „zwischen der Hauptebene und der Hintergrundebene“ liegt. Sie können fill between/on layer=maindies also auf die Ebene verschieben, auf der alle anderen Dinge gezeichnet werden. Ich würde auch hinzufügen axis on top:

%https://tex.stackexchange.com/questions/671424/pgfplot-fill-between-while-including-decoration-function
\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{decorations.markings}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            axis lines=center,
            xmin=0, xmax=12.5,
            ymin=0, ymax=15,
            axis on top,
            fill between/on layer=main
        ]
            \fill[blue!60] (7,7.8) -- (8.3,7.8) -- (7,9.5) -- cycle;
            \draw[violet, line width=3pt] (7,7.5) -- (7,10);
            \filldraw[brown!40, draw=blue, line width=2pt] 
                (6,6.5) -- (5.5,7.5) -- (8.5,7.5) -- (8,6.5) -- cycle; 
            \node at (6.3,7.2) () {\tiny \LaTeX};
            \draw[name path=line] (0,0) -- (12,0);
            \addplot[
                name path=plot, 
                cyan,
                domain=0:12,
                preaction={decorate},
                samples=100,                
            ] {.1*sin(3*x*180/pi)+7};
            \addplot[fill=cyan!40, opacity=0.5] fill between [of=line and plot];
        \end{axis}    
    \end{tikzpicture}
\end{document}

Bildbeschreibung hier eingeben

Antwort2

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
axis on top,
xmin=0, xmax=12.5,
ymin=0, ymax=15,
]
\fill[blue!60] (7,7.8) -- (8.3,7.8) -- (7,9.5) --cycle;
\draw[violet, line width=3pt] (7,7.5) -- (7,10);
\filldraw[blue, fill=brown!40, line width=2pt] (6,6.5) -- (5.5,7.5) -- (8.5,7.5) -- (8,6.5) --cycle; 
\node at (6.3,7.2) {\tiny \LaTeX};
\fill[cyan!40, opacity=0.5] plot[domain=0:12, smooth] (\x,{.1*sin(3*\x*180/pi)+7}) |- (current axis.south) -|cycle;
\draw[cyan] plot[domain=0:12, smooth] (\x,{.1*sin(3*\x*180/pi)+7});
\end{axis}    
\end{tikzpicture}
\end{document}

Graph mit Wasser und einem Boot

\draw[cyan] plot[domain=0:12.18, samples=100, smooth, variable=\t] ({\t+.2*cos(\t*180-180)},{.3*sin(\t*180-120)+7});

Graph mit welligem Wasser und einem Boot

verwandte Informationen