pgfplots에서`\ closedcycle`“및”`fill` "옵션의 참 조선 변경

Nov 24 2020

Matlab2tikz 패키지를 사용하여 Matlab에서 그린 일부 플롯의 tikz 파일을 얻었습니다. " fill"옵션을 사용하여 컬러 신뢰 구간을 표시하는 데 문제가 있습니다. 내 추측은 문제가 " \closedcycle"및 " fill"옵션에 대한 참 조선 이 y = 0 (또는 x 축)이고 곡선과 y = 0 (또는 x 축) 사이의 영역이 색상 이 지정된다는 사실에서 비롯된 것입니다. , 따라서 곡선이 x 축을 가로 지르는 경우 색상이 지정된 신뢰 구간은 허용되지 않습니다.

Matlab2tikz에서 생성 된 주목할만한 플롯 수를 고려할 때 코드를 최소한으로 변경하여 문제를 해결하는 것이 중요합니다. 이 변경 사항은 기준선을 y = ymin으로 이동시킬 수 있다고 생각합니다. 이 링크\closedcycleymin 와 비슷한 새로운 명령을 정의해야한다고 생각 합니다 .\closedcycley

해결책을 찾도록 도와 주시겠습니까?

베스트

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}
\begin{axis}[%
width=1.245in,
height=0.895in,
at={(0.758in,1.792in)},
scale only axis,
xmin=1,
xmax=20,
ymin=-0.00272712850308932,
ymax=0.000803621131163322,
axis background/.style={fill=white},
title style={font=\bfseries},
title={ph}
]
\addplot[fill=white!90!black, draw=black, forget plot] table[row sep=crcr]{%
    1   -0.000821339838121972\\
    2   -0.00164043467432739\\
    3   -0.000895855599007665\\
    4   -0.000315424225262793\\
    5   0.000146513747520635\\
    6   0.000490017617162638\\
    7   0.000687017984049317\\
    8   0.000783609682610873\\
    9   0.000803621131163322\\
    10  0.00073111890779905\\
    11  0.00064470236661438\\
    12  0.000533672630962923\\
    13  0.000438218545990327\\
    14  0.000349701399270754\\
    15  0.000244212703270491\\
    16  0.00016698621322208\\
    17  0.000119605897750126\\
    18  7.82908188883209e-05\\
    19  5.34333417323973e-05\\
    20  4.07765839765695e-05\\
}
\closedcycle;
\addplot[fill=white, draw=black, forget plot] table[row sep=crcr]{%
    1   -0.00140736744545601\\
    2   -0.00272712850308932\\
    3   -0.00192479768024259\\
    4   -0.00131335464603441\\
    5   -0.000783836032350087\\
    6   -0.000318439289539476\\
    7   3.60206971690225e-05\\
    8   0.000282621786338977\\
    9   0.000410640041633922\\
    10  0.000406665195391912\\
    11  0.000341989605677194\\
    12  0.000231338661868178\\
    13  0.000148732813468034\\
    14  8.29434473632843e-05\\
    15  8.70901360309242e-06\\
    16  -2.16298098251486e-05\\
    17  -3.09431658059387e-05\\
    18  -3.62579623929987e-05\\
    19  -3.49849226862417e-05\\
    20  -2.9692048179123e-05\\
}
\closedcycle;
\addplot [color=black, line width=3.0pt, forget plot]
table[row sep=crcr]{%
    1   -0.00112518900664359\\
    2   -0.00213651644225243\\
    3   -0.00138090837487913\\
    4   -0.000826424694277475\\
    5   -0.000332414099773573\\
    6   9.50139834939742e-05\\
    7   0.000381511379481362\\
    8   0.000536434127747512\\
    9   0.000585284480227507\\
    10  0.000557350139363697\\
    11  0.000483026729034827\\
    12  0.000387974647548721\\
    13  0.000291042096495643\\
    14  0.000204281289809255\\
    15  0.000133847420764794\\
    16  8.1421682770134e-05\\
    17  4.57275008939389e-05\\
    18  2.38646695963638e-05\\
    19  1.23435421254728e-05\\
    20  7.79003027335727e-06\\
};
\end{axis}
\end{tikzpicture}
\end{document}

답변

Qaher Nov 24 2020 at 17:12

귀하의 질문은 약간 모호하지만 이것이 제가 깨달은 것입니다. 여기 에있는이 주석을 기반으로 서문에 다음 명령을 입력하면됩니다.

\newcommand{\myclosedcycle}{|- (axis description cs:0,0) |- (current plot begin)}

이제 \myclosedcycle대신 \closedcycle. 다음은 실행 후 출력입니다.

% Qaher Marufiazar
\documentclass{article}
\usepackage{pgfplots}

\newcommand{\myclosedcycle}{|- (axis description cs:0,0) |- (current plot begin)}
\begin{document}
    \begin{tikzpicture}
\begin{axis}[%
width=1.245in,
height=0.895in,
at={(0.758in,1.792in)},
scale only axis,
xmin=1,
xmax=20,
ymin=-0.00272712850308932,
ymax=0.000803621131163322,
title style={font=\bfseries},
title={ph}
]
\addplot[fill=white!90!black, draw=black, forget plot] table[row sep=crcr]{%
    1   -0.000821339838121972\\
    2   -0.00164043467432739\\
    3   -0.000895855599007665\\
    4   -0.000315424225262793\\
    5   0.000146513747520635\\
    6   0.000490017617162638\\
    7   0.000687017984049317\\
    8   0.000783609682610873\\
    9   0.000803621131163322\\
    10  0.00073111890779905\\
    11  0.00064470236661438\\
    12  0.000533672630962923\\
    13  0.000438218545990327\\
    14  0.000349701399270754\\
    15  0.000244212703270491\\
    16  0.00016698621322208\\
    17  0.000119605897750126\\
    18  7.82908188883209e-05\\
    19  5.34333417323973e-05\\
    20  4.07765839765695e-05\\
}
\myclosedcycle ;
\addplot[fill=white, draw=black, forget plot] table[row sep=crcr]{%
    1   -0.00140736744545601\\
    2   -0.00272712850308932\\
    3   -0.00192479768024259\\
    4   -0.00131335464603441\\
    5   -0.000783836032350087\\
    6   -0.000318439289539476\\
    7   3.60206971690225e-05\\
    8   0.000282621786338977\\
    9   0.000410640041633922\\
    10  0.000406665195391912\\
    11  0.000341989605677194\\
    12  0.000231338661868178\\
    13  0.000148732813468034\\
    14  8.29434473632843e-05\\
    15  8.70901360309242e-06\\
    16  -2.16298098251486e-05\\
    17  -3.09431658059387e-05\\
    18  -3.62579623929987e-05\\
    19  -3.49849226862417e-05\\
    20  -2.9692048179123e-05\\
} \myclosedcycle ;
\addplot [color=black, line width=3.0pt, forget plot]
table[row sep=crcr]{%
    1   -0.00112518900664359\\
    2   -0.00213651644225243\\
    3   -0.00138090837487913\\
    4   -0.000826424694277475\\
    5   -0.000332414099773573\\
    6   9.50139834939742e-05\\
    7   0.000381511379481362\\
    8   0.000536434127747512\\
    9   0.000585284480227507\\
    10  0.000557350139363697\\
    11  0.000483026729034827\\
    12  0.000387974647548721\\
    13  0.000291042096495643\\
    14  0.000204281289809255\\
    15  0.000133847420764794\\
    16  8.1421682770134e-05\\
    17  4.57275008939389e-05\\
    18  2.38646695963638e-05\\
    19  1.23435421254728e-05\\
    20  7.79003027335727e-06\\
};
\end{axis}
\end{tikzpicture}
\end{document}