從平滑中排除某些繪圖點

從平滑中排除某些繪圖點
  1. 如何排除 PGF 圖中「平滑」選項平滑的某些座標?
  2. 如何避免\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}

結果圖

問題有兩個:

  1. 由於平滑,橙色三角形的左角繪製錯誤。 (如果放大生成的 PDF,人們可以更輕鬆地看到這一點。)我需要一個smooth選項,使橙色圖正確跟隨藍色圖(前半部分)和紅色圖(後半部分)。但是,橙色圖停止跟隨藍色圖並開始跟隨紅色圖的點不得進行平滑,因為它是不可微點。是否有任何選項可以從平滑中排除繪圖的單點?
  2. 橙色圖以 終止,\closedcycle因為我想fill稍後使用該選項。但這使得情節首先跳到零,正如人們從圖片中看到的那樣。是否有任何選項可以透過從終點到起點的直線來結束繪圖?

答案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}

在此輸入影像描述

相關內容