您是否发现该点(0.78951,1.38506)
比前一个点略低,而它应该位于其上方?
\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,amsfonts,systeme} % Typical maths resource packages
\usepackage{color} % For creating coloured text and background
\usepackage{array}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{arrows.meta}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
grid, grid style=dashed,
xticklabel style={rotate=90},
ymin=1.33,ymax=1.39,
extra y ticks={1.33,1.35,1.37}, % <---
xmax=1,xmin=0,
extra x ticks={0}, % <---
xtick={0,0.20594,0.38019,0.62664,0.78951,1},
minor tick num=1,
axis lines = middle,
set layers, % <---
%axis on top, % <---
xlabel=$x_1$,ylabel=$n_D$,
x label style={at={(1,0)},right},
y label style={at={(0,1)},above},
x tick label style={/pgf/number format/.cd,
fixed relative,
/pgf/number format/precision=5
},
style={thick}
]
\addplot+[color=red,mark=*,mark options={draw=red,fill=green},thick,smooth]
coordinates {
(0.00000, 1.33300)(0.20594,1.37003)(0.38019,1.37944)(0.62664,1.38502)(0.78951,1.38506)(1.00000,1.38511)
};
\end{axis}
\end{tikzpicture}
\end{document}
是只有我一个人这样,还是真的这样?在这种情况下,你有什么建议吗?
先感谢您
答案1
这是视觉效果,因为红色曲线在点 (0.65664, 1.38502) 处的斜率相对于点 (0.65664, 1.38502) 和 (0.78951,1.38506) 之间的 (实际) 斜率太大。您可以在此放大的屏幕截图 (带有蓝色水平线) 中看到,点 (0.78951,1.38506) 实际上高于前一个点。
\pgfplotsset{compat=1.16}
请注意代码中添加的这一行:
\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,amsfonts,systeme} % Typical maths resource packages
\usepackage{color} % For creating coloured text and background
\usepackage{array}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{arrows.meta}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepackage{filecontents}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
grid, grid style=dashed,
xticklabel style={rotate=90},
ymin=1.33,ymax=1.39,
extra y ticks={1.33,1.35,1.37}, % <---
xmax=1,xmin=0,
extra x ticks={0}, % <---
xtick={0,0.20594,0.38019,0.62664,0.78951,1},
minor tick num=1,
axis lines = middle,
set layers, % <---
%axis on top, % <---
xlabel=$x_1$,ylabel=$n_D$,
x label style={at={(1,0)},right},
y label style={at={(0,1)},above},
x tick label style={/pgf/number format/.cd,
fixed relative,
/pgf/number format/precision=5
},
style={thick}
]
\addplot+[color=red,mark=*,mark options={draw=red,fill=green},thick,smooth]
coordinates {
(0.00000, 1.33300)(0.20594,1.37003)(0.38019,1.37944)(0.62664,1.38502)(0.78951,1.38506)(1.00000,1.38511)
};
\draw[ultra thin, blue] (0.62,1.38410)--(0.8,1.38410) ;
\draw[ultra thin, violet] (0.62664,1.38502) -- (0.70,1.38570);
\end{axis}
\end{tikzpicture}
\end{document}
tension
您可以通过减少(默认情况下为 0.55)来 减轻这种影响:\addplot+[color=red,mark=*,mark options={draw=red,fill=green},thick,smooth,tension=0.25]