13

Do you see the point (0.78951,1.38506) is slightly below the previous one, while it should be above?

\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}

enter image description here

Is it just me, or is it really like that? In this case, do you have any suggestions?

Thank you in advance

2
  • Try removing smooth and see what happens?
    – zdm
    Commented May 12, 2019 at 8:22
  • 1
    If you like an answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and marking it as accepted answer (by clicking on the checkmark ✓). In this instance, quark67 clearly deserves the tick, I think.
    – user30471
    Commented May 15, 2019 at 8:43

2 Answers 2

23

It's a optical effect because the slope of the red curve at point (0.65664, 1.38502) is too big relative to the (real) slope between the points (0.65664, 1.38502) and (0.78951,1.38506). You can see in this magnified screenshot (with the blue horizontal line) that the point (0.78951,1.38506) is really above the previous one.

Note the adding of the line \pgfplotsset{compat=1.16} in the code:

\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}

enter image description here enter image description here

You could reduce this effect by reducing the tension (by default, it is 0.55): \addplot+[color=red,mark=*,mark options={draw=red,fill=green},thick,smooth,tension=0.25]

give: enter image description here

10

The point at 0.79 is not actually lower. Rather the interpolated graph keeps increasing after the point at 0.62 and this makes it look as if the point as 0.79 is lower. You can see that this is the case by magnifying the graph and just looking at these two points. The image below shows that the point at 0.79, on the right, is indeed slightly higher than the point at 0.62:

enter image description here

[This is really an extended comment, except that you can't put images into comments...]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .