- PGF プロットの「スムーズ」オプションによって特定の座標がスムーズ化されないようにするにはどうすればよいですか?
\closedcycle
ゼロにジャンプするのを避けるにはどうすればよいですか?
私の例は次のとおりです。
\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}
問題は2つあります。
- オレンジ色の三角形の左隅は、スムージングにより間違ってプロットされています。(結果の PDF を拡大すると、それが簡単にわかります。)
smooth
オレンジ色のプロットが青色のプロット (前半) と赤色のプロット (後半) に正しく追従するオプションが必要です。ただし、オレンジ色のプロットが青色のプロットの追従を止め、赤色のプロットの追従を開始するポイントは、微分不可能なポイントであるため、スムージングしてはなりません。プロットの個々のポイントをスムージングから除外するオプションはありますか? - オレンジ色のプロットは、後でオプション
\closedcycle
を使用したいので、で終了していますfill
。しかし、これにより、図からわかるように、プロットは最初にゼロにジャンプします。終了点から開始点まで直線でプロットを閉じるオプションはありますか?
答え1
最新のpgfplots
バージョン (1.10) には、fillbewteen
2 つの曲線間の任意の領域を塗りつぶすことができる新しいライブラリが含まれています。
すべてのパス ( ) に名前を割り当て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}