- PGF 플롯에서 "부드러운" 옵션으로 특정 좌표를 평활화하지 않도록 하려면 어떻게 해야 합니까?
\closedcycle
0으로 점프하는 것을 어떻게 방지합니까 ?
내 예는 다음과 같습니다.
\documentclass{minimal}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xtick=\empty,
ytick=\empty,
plot a/.style={semithick,red,smooth},
plot b/.style={semithick,blue,smooth},
plot error/.style={thick,orange,smooth},
]
\addplot[plot a] coordinates {
(1.400,0.484) (1.450,0.464) (1.500,0.442) (1.550,0.419) (1.600,0.395) (1.650,0.370)
(1.700,0.346) (1.750,0.321) (1.800,0.297) (1.850,0.273) (1.900,0.249) (1.950,0.227)
(2.000,0.205) (2.050,0.185) (2.100,0.166) (2.150,0.148) (2.200,0.131) (2.250,0.116)
(2.300,0.102) (2.350,0.089) (2.400,0.077) (2.450,0.067) (2.500,0.057) };
\addplot[plot b] coordinates {
(1.400,0.111) (1.450,0.120) (1.500,0.130) (1.550,0.139) (1.600,0.150) (1.650,0.160)
(1.700,0.171) (1.750,0.183) (1.800,0.194) (1.850,0.206) (1.900,0.218) (1.950,0.230)
(2.000,0.242) (2.050,0.254) (2.100,0.266) (2.150,0.278) (2.200,0.290) (2.250,0.301)
(2.300,0.312) (2.350,0.323) (2.400,0.333) (2.450,0.343) (2.500,0.352) };
\addplot[plot error] coordinates{
(2.300,0.312) (2.250,0.301) (2.200,0.290) (2.150,0.278) (2.100,0.266) (2.050,0.254)
(2.000,0.242) (1.950,0.230) (1.946,0.2287) (1.950,0.227) (2.000,0.205) (2.050,0.185)
(2.100,0.166) (2.150,0.148) (2.200,0.131) (2.250,0.116) (2.300,0.102) } \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}
문제는 두 가지입니다.
- 주황색 삼각형의 왼쪽 모서리가 평활화로 인해 잘못 표시되었습니다. (결과 PDF를 확대하면 더 쉽게 볼 수 있습니다.)
smooth
주황색 플롯이 파란색 플롯(전반)과 빨간색 플롯(후반)을 올바르게 따르도록 하는 옵션이 필요합니다. 그러나 주황색 플롯이 파란색 플롯을 따르기를 멈추고 빨간색 플롯을 따르기 시작하는 지점은 미분 불가능한 지점이기 때문에 평활화해서는 안 됩니다. 플롯의 단일 지점을 평활화에서 제외할 수 있는 옵션이 있습니까? - 나중에 옵션을
\closedcycle
사용하고 싶기 때문에 주황색 플롯이 종료됩니다 .fill
그러나 그림에서 볼 수 있듯이 이로 인해 플롯이 먼저 0으로 점프하게 됩니다. 끝에서 시작점까지 직선으로 플롯을 닫는 옵션이 있습니까?
답변1
가장 최근의 것을 사용할 수 있는 경우pgfplots
버전(1.10)에는 fillbewteen
두 곡선 사이의 모든 영역을 채울 수 있는 새로운 라이브러리가 포함되어 있습니다.
모든 경로( )에 이름을 할당 name path=
하고 나중에 이 이름을 사용하여 경로 사이의 영역을 채워야 합니다.
or
이 솔루션을 사용하면 '매끄러운 미분 불가능 점' 에 문제가 없습니다 .
\documentclass[border=3mm]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
%\pgfplotsset{compat=1.9}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xtick=\empty,
ytick=\empty,
plot a/.style={semithick,red,smooth},
plot b/.style={semithick,blue,smooth},
plot error/.style={thick,orange,smooth},
]
\addplot[plot a, name path=A] coordinates {
(1.400,0.484) (1.450,0.464) (1.500,0.442) (1.550,0.419) (1.600,0.395) (1.650,0.370)
(1.700,0.346) (1.750,0.321) (1.800,0.297) (1.850,0.273) (1.900,0.249) (1.950,0.227)
(2.000,0.205) (2.050,0.185) (2.100,0.166) (2.150,0.148) (2.200,0.131) (2.250,0.116)
(2.300,0.102) (2.350,0.089) (2.400,0.077) (2.450,0.067) (2.500,0.057) };
\addplot[plot b, name path=B] coordinates {
(1.400,0.111) (1.450,0.120) (1.500,0.130) (1.550,0.139) (1.600,0.150) (1.650,0.160)
(1.700,0.171) (1.750,0.183) (1.800,0.194) (1.850,0.206) (1.900,0.218) (1.950,0.230)
(2.000,0.242) (2.050,0.254) (2.100,0.266) (2.150,0.278) (2.200,0.290) (2.250,0.301)
(2.300,0.312) (2.350,0.323) (2.400,0.333) (2.450,0.343) (2.500,0.352) };
%\addplot[plot error, name path=C] coordinates{
%(2.300,0.312) (2.250,0.301) (2.200,0.290) (2.150,0.278) (2.100,0.266) (2.050,0.254)
%(2.000,0.242) (1.950,0.230) (1.946,0.2287) (1.950,0.227) (2.000,0.205) (2.050,0.185)
%(2.100,0.166) (2.150,0.148) (2.200,0.131) (2.250,0.116) (2.300,0.102) } \closedcycle;
%\draw[name path=vertical] (axis cs:2.3,0)--(axis cs:2.3,5);
\addplot[fill=none] fill between [of=A and B,
soft clip={domain=1:2.3},
split,
every segment no 1/.style={fill=orange}];
\end{axis}
\end{tikzpicture}
\end{document}