pgfplots,超调问题

pgfplots,超调问题

如何才能避免低于 0 的超调?

图形

这是我使用的代码:

\documentclass{article}
\usepackage{etex}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{ternary}
\usepgfplotslibrary{groupplots}
\usetikzlibrary{pgfplots.groupplots}

 \begin{document}

 \begin{tikzpicture}


\pgfplotsset{every axis/.append style={solid},
    every tick/.append style={semithick,color=black}, 
}


\begin{axis}[smooth,

scale only axis = true, width = 0.9\textwidth , height = 0.35\textwidth,
scaled ticks = false,
minor tick num =0,
thick,
ymin =-0.2, ymax =0.7, xmin =0,  xmax=72, 

legend style={font=\footnotesize, 
    legend pos =north west},

tickwidth = 0.15cm,
grid style ={dashed},

ylabel = {y}, 
xlabel={x},
grid = both
]


\addplot [no markers] coordinates{
(0,0.5)
(2,0.0)
(4,0.01)
(6,0.02)
(8,0.03)
(10,0.06)
(12,0.09)
(14,0.13)
(16,0.18)
(18,0.23)
(20,0.28)
(22,0.32)
(24,0.36)
(26,0.40)
(28,0.43)
(30,0.46)
(32,0.48)
(34,0.50)
(36,0.51)
(38,0.53)
(40,0.54)



} ;

\end{axis}
\end{tikzpicture}
\end{document}

答案1

您有以下几种选择:

  • 不要使用smooth,这会产生硬角(下面未显示),
  • 设置tension为较低的值,可以减少过冲,但会使拐角更难,
  • 如果允许的话,你可以加一分,或者
  • 你可以结合最后两个选项(下面未显示)

(图例显示了 的值tension。)

在此处输入图片描述

\documentclass{article}
\usepackage{etex}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{ternary}
\usepgfplotslibrary{groupplots}
\usetikzlibrary{pgfplots.groupplots}

 \begin{document}

 \begin{tikzpicture}


\pgfplotsset{every axis/.append style={solid},
    every tick/.append style={semithick,color=black}, 
}


\begin{axis}[smooth,
%
scale only axis = true, width = 0.9\textwidth , height = 0.35\textwidth,
scaled ticks = false,
minor tick num =0,
thick,
ymin =-0.2, ymax =0.7, xmin =0,  xmax=72, 
%
legend style={font=\footnotesize, 
    legend pos =north west},
%
tickwidth = 0.15cm,
grid style ={dashed},
%
ylabel = {y}, 
xlabel={x},
grid = both
]


\addplot+[no markers,tension=0.2] coordinates{
(0,0.5)
(2,0.0)
(4,0.01)
(6,0.02)
(8,0.03)
(10,0.06)
(12,0.09)
(14,0.13)
(16,0.18)
(18,0.23)
(20,0.28)
(22,0.32)
(24,0.36)
(26,0.40)
(28,0.43)
(30,0.46)
(32,0.48)
(34,0.50)
(36,0.51)
(38,0.53)
(40,0.54)
} ;
\addlegendentry{0.2}

% default value: tension=0.55
\addplot+[no markers] coordinates{
(0,0.5)
(2,0.0)
(4,0.01)
(6,0.02)
(8,0.03)
(10,0.06)
(12,0.09)
(14,0.13)
(16,0.18)
(18,0.23)
(20,0.28)
(22,0.32)
(24,0.36)
(26,0.40)
(28,0.43)
(30,0.46)
(32,0.48)
(34,0.50)
(36,0.51)
(38,0.53)
(40,0.54)
} ;
\addlegendentry{0.55 (default)}

\addplot+[no markers,tension=0.9] coordinates{
(0,0.5)
(2,0.0)
(4,0.01)
(6,0.02)
(8,0.03)
(10,0.06)
(12,0.09)
(14,0.13)
(16,0.18)
(18,0.23)
(20,0.28)
(22,0.32)
(24,0.36)
(26,0.40)
(28,0.43)
(30,0.46)
(32,0.48)
(34,0.50)
(36,0.51)
(38,0.53)
(40,0.54)
} ;
\addlegendentry{0.9}

\addplot+[no markers] coordinates{
(0,0.5)
(1,0.1) % added point
(2,0.0)
(4,0.01)
(6,0.02)
(8,0.03)
(10,0.06)
(12,0.09)
(14,0.13)
(16,0.18)
(18,0.23)
(20,0.28)
(22,0.32)
(24,0.36)
(26,0.40)
(28,0.43)
(30,0.46)
(32,0.48)
(34,0.50)
(36,0.51)
(38,0.53)
(40,0.54)
} ;
\addlegendentry{added point}
\end{axis}
\end{tikzpicture}
\end{document}

相关内容