두 함수 사이 채우기

두 함수 사이 채우기

아래 예에서 저는 두 장의 사진을 제시하려고 합니다. 하나는 파도 프로필과 선박 프로필 사이에 음영이 있는 사진(성공)이고 다른 하나는 흘수선 \zeta=0과 왜곡된 수중 선체 프로필 사이에 음영이 있는 사진(성공하지 못함)입니다. .동일한 fill between구문을 사용했고 많은 게시물을 정독했지만 내 오류를 찾을 수 없는 것 같습니다. 누구에게나 명백합니까?

% Hull Mapping Diagram
% Author: Richard W. Greenwood
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{calc}
\usepackage{amssymb}
\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{10pt}%
%%%>
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\usetikzlibrary{intersections}
\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}


\begin{document}


\begin{comment}
:Title: Hull Mapping
:Author: Richard W. Greenwood
\end{comment}

\pgfmathdeclarefunction{wave}{0}{\pgfmathparse{-0.25*cos(\x r)}}
\pgfmathdeclarefunction{tr_wave}{0}{\pgfmathparse{0}}
\pgfmathdeclarefunction{deck}{0}{\pgfmathparse{0.5}}
\pgfmathdeclarefunction{tr_deck}{0}{\pgfmathparse{0.5+0.25*cos(\x r)}}
\pgfmathdeclarefunction{buttock}{0}{\pgfmathparse{-0.5-0.125*(\x)}}
\pgfmathdeclarefunction{skeg}{0}{\pgfmathparse{-8.2-3.9*(\x)}}
\pgfmathdeclarefunction{keel}{0}{\pgfmathparse{-0.5}}
\pgfmathdeclarefunction{stem}{0}{\pgfmathparse{-10.5+3.5*(\x)}}

\pgfplotsset{width=10cm, compat=1.10}

\begin{tikzpicture}
[declare function={keelp(\x)=
(\x>=0.94*pi)*(-10.5+3.5*(\x))+and
(\x>-0.66*pi,\x<0.94*pi)*(-0.5)+
(\x<=-0.66*pi)*(-0.5+\x*-0.125);}]

[yscale=1.0]
\begin{axis}[
    axis equal image,
    xtick       = \empty,
    ytick       = \empty,
    axis lines =middle,
    samples     = 160,
    domain      = -1.5*pi:1.5*pi,
    xmin = -1.3*pi, xmax = 1.4*pi,
    ymin = -0.75, ymax = 1.35,
    title style={at={(0.5,-0.2)},anchor=north},
 title = actual immersed hull surface,
  ]
\addplot[name path=keelprofile, red,domain={-pi:pi}]{keelp(x)};
\addplot[name path=wave, blue, thick, domain={-1.25*pi:1.25*pi} ] {wave};
%\addplot[name path=tr_wave, blue, thick, domain={-1.25*pi:1.25*pi} ] {tr_wave};
%\addplot[name path=tr_profile, green, thick, domain={-pi:0.97*pi} ] {-(wave-keelprofile(x))};
%\addplot[name path=tr_deck, green, thin, mark=none, domain={-1.*pi:1.*pi}] {tr_deck};
\addplot[name path=deck, red, thin, mark=none, domain={-1.*pi:1.*pi}] {deck};
\addplot[name path=transom,red, thin] coordinates {(-pi,-0.1)(-pi,0.5)};
\addplot[black, thin] coordinates {(0,-0.75)(0,0.9)}node[anchor=south west,black]{$z$};
\addplot[black, thin] coordinates {(-1.3*pi,0)(1.35*pi,0)}node[anchor=south,black]{$x$};
\addplot [pattern=north west lines, pattern color=brown!50]fill between[ of = wave and keelprofile, soft clip={domain=-pi:0.97*pi}];
  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
[declare function={
keelp(\x)=
(\x>=0.94*pi)*(-10.5+3.5*(\x))+and
(\x>-0.66*pi,\x<0.94*pi)*(-0.5)+
(\x<=-0.66*pi)*(-0.5+\x*-0.125);
trp(\x)=
(\x>=0.94*pi)*(-10.5+3.5*(\x)+0.25*cos(\x r))+and
(\x>-0.66*pi,\x<0.94*pi)*(-0.5+0.25*cos(\x r))+
(\x<=-0.66*pi)*(-0.5+\x*-0.125+0.25*cos(\x r));
}]
[yscale=1.0]
\begin{axis}[
    axis equal image,
    xtick       = \empty,
    ytick       = \empty,
    axis lines =middle,
    samples     = 160,
    domain      = -1.5*pi:1.5*pi,
    xmin = -1.3*pi, xmax = 1.4*pi,
    ymin = -0.75, ymax = 1.35,
    title style={at={(0.5,-0.2)},anchor=north},
 title = transformed immersed hull surface,
  ]
\addplot[name path=tr_wave, blue, thick, domain={-1.25*pi:1.25*pi} ] {tr_wave};
%\addplot[name path=tr_profile, red, thin, domain={-pi:pi} ] {keelp(x)-wave};
\addplot[name path=trp, red, thin, domain={-pi:pi} ] {trp(x)};
\addplot[name path=tr_deck, red, thin, mark=none, domain={-1.*pi:1.*pi}] {tr_deck};
\addplot[name path=tr_transom,red, thin] coordinates {(-pi,-0.35)(-pi,0.25)};
\addplot[black, thin] coordinates {(0,-0.75)(0,0.9)}node[anchor=south west,black]{$\xi$};
\addplot[black, thin] coordinates {(-1.3*pi,0)(1.35*pi,0)}node[anchor=south,black]{$x$};
\addplot [pattern=north west lines, pattern color=brown!50]fill between[ of = tr_wave and trp, soft clip={domain=-pi:0.97*pi}];
  \end{axis}
\end{tikzpicture}

\end{document}

여기에 이미지 설명을 입력하세요

답변1

업데이트된 답변

보고된 버그가 수정되었으며 PGFPlots v1.16이 출시되면서 귀하의 예가 예상된 결과를 직접 제공합니다.

원래 답변

이는 이미 보고된 내용과 관련이 있습니다.벌레fill between와 함께 사용하면 PGFPlots에서 soft clip축 경계에 부딪힙니다. 따라서 해결책은 간단합니다. ymin값을 더 낮은 값(예: )으로 설정 -0.76하면 원하는 결과를 얻을 수 있습니다.

여기서는 코드의 관련 부분(그리고 이 이상한 동작이 어디서 오는지 증명하기 위한 몇 가지 추가 항목)의 결과만 보여줍니다.

% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \usetikzlibrary{
        patterns,
        pgfplots.fillbetween,
    }
    \pgfplotsset{
        compat=1.11,
        width=10cm,
    }
    \pgfmathdeclarefunction{tr_wave}{0}{\pgfmathparse{0}}
\begin{document}
    \begin{tikzpicture}[
        declare function={
            trp(\x) =
                (\x>=0.94*pi)*(-10.5+3.5*(\x)+0.25*cos(\x r))
                + and(\x>-0.66*pi,\x<0.94*pi)*(-0.5+0.25*cos(\x r))
                + (\x<=-0.66*pi)*(-0.5+\x*-0.125+0.25*cos(\x r))
            ;
        },
    ]
        \begin{axis}[
            axis equal image,
            xtick=\empty,
            ytick=\empty,
            axis lines =middle,
            samples=160,
            xmin=-1.3*pi,
            xmax=1.4*pi,
            % -----------------------------------------------------------------
            % that is the important line here
            % it is equal or greater than the minimum value of one of the
            % `fill between' pathes and thus causes the strange behaviour
            % in combination with the `soft clip' path
            ymin=-0.76,         % <-- changed from -0.75
            % -----------------------------------------------------------------
            ymax=1.35,
            title style={
                at={(0.5,-0.2)},
                anchor=north,
            },
            title=transformed immersed hull surface,
        ]
            \addplot [
                name path=tr_wave,
                blue,
                thick,
                domain={-1.25*pi:1.25*pi},
            ] {tr_wave};
            \addplot [
                name path=trp,
                red,
                thin,
                domain={-pi:pi},
            ] {trp(x)};

            \addplot [
                pattern=north west lines,
                pattern color=brown!50,
            ] fill between [
                of=tr_wave and trp,
                % to prove that the soft clip is responsible for the bug
                % use e.g. a `ymin' value between -0.70 and -0.75,
                % comment the `soft clip' path and you will get the desired result
                soft clip={
                    domain=-pi:0.97*pi,
%                    % comment the previous line and use the next one which
%                    % should give the same result as when no `soft clip` path
%                    % is used
%                    % (same domain as `tr_wave')
%                    domain=-1.25*pi:1.25*pi,
                },
            ];

            % this line shows you the previous `ymin' and that it touched one
            % of the pathes relevant for the `fill between'
            \draw [help lines, dashed]
                (\pgfkeysvalueof{/pgfplots/xmin},-0.75)
                -- (\pgfkeysvalueof{/pgfplots/xmax},-0.75)
            ;
        \end{axis}
    \end{tikzpicture}
\end{document}

위 코드의 결과를 보여주는 이미지

관련 정보