如何突出显示图上的两个最小点?

如何突出显示图上的两个最小点?

代码:

\documentclass[preview]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{caption}

\begin{document}
    \begin{figure}
    \centering
\begin{tikzpicture}
  \begin{axis}[
    name=border,
    title=min point? how much less from 2nd min?,
    xlabel=$steps$,
    ylabel=$cost$]
    \addplot coordinates {
        (10, 1.07379615996e+13) 
        (20, 1.07856445335e+13)
        (30, 1.0766173662e+13)
        (40, 1.07576350033e+13)
        (50, 1.07507770146e+13)
        (60, 1.07456785887e+13)
        (70, 1.07426580974e+13)
        (80, 1.07414232715e+13)
        (90, 1.0740077238e+13)
       (100, 1.07381696222e+13)
    };
    \node [below] at (axis cs:  10, 1.07379615996e+13) {$1.07379615996e+13$};
    \node [below] at (axis cs:  100, 1.07381696222e+13) {$1.07381696222e+13$};
  \end{axis}
\end{tikzpicture}
\caption{Le caption}
    \end{figure}
\end{document}

输出:

在此处输入图片描述

我们能做得更好吗?我认为可以!从两个最低点(硬编码)画两条水平线,并在 y 轴上显示它们的准确值,这不是很酷吗?或者其他任何方法,都比我上面的蛮力尝试(为这两个点使用标签)要好。

答案1

我会extra y ticks

\begin{tikzpicture}
  \begin{axis}[
    name=border,
    title=min point? how much less from 2nd min?,
    xlabel=$steps$,
    ylabel=$cost$,
    extra y ticks = {1.07379615996e+13,1.07381696222e+13},
    extra y tick style={grid=major, grid style={solid,black},y tick label style={
            /pgf/number format/.cd,precision=10
    }},   
    ]
    \addplot coordinates {
        (10, 1.07379615996e+13) 
        (20, 1.07856445335e+13)
        (30, 1.0766173662e+13)
        (40, 1.07576350033e+13)
        (50, 1.07507770146e+13)
        (60, 1.07456785887e+13)
        (70, 1.07426580974e+13)
        (80, 1.07414232715e+13)
        (90, 1.0740077238e+13)
       (100, 1.07381696222e+13)
    };
  \end{axis} 
\end{tikzpicture}

但正如其他人指出的那样,这些价值观太接近了。

在此处输入图片描述

相关内容