如何让 xmin 和 xmax 在小间隔内工作?

如何让 xmin 和 xmax 在小间隔内工作?

下面使用由 x = 0 和 x = 2 界定的巨大数据集的一小部分样本。但是,需要在区间 [1.371508664312009 1.371508780212562] 处绘制结果。但是,这不适用于以下代码。哪里出了问题?(我显然可以缩放结果,但我想要一个更通用的解决方案,因为这在我的论文中经常发生)

\documentclass[tikz,border=2pt,png]{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        cycle list={%
            {black}
        },
        xmin = 1.371508664312009,
        xmax = 1.371508780212562,
        ]
        \addplot[unbounded coords=discard] table[x=k,y=F_k] {
k                   F_k
1.371508647597729   4.218629299064943
1.371508655954869   4.367306455608867
1.371508664312009   4.546736697704027
1.371508672669148   4.767650229729832
1.371508710724181   7.117825185499241
1.371508713560441   7.513271582940213
1.371508716396702   7.985684237353307
1.371508719232962   8.552417433810986
1.371508722069223   9.245525102110591
1.371508724905483   10.115770661107760
1.371508727741744   11.225899722988125
1.371508730578004   12.667837277184283
1.371508737113507   17.998622084719759
1.371508738663157   19.703601372911169
1.371508739179707   20.274665134457187
1.371508739696257   20.825915113218606
1.371508742279008   22.855385665696630
1.371508742795558   22.988513291704997
1.371508745120034   21.959402178915621
1.371508745636584   21.414072973829519
1.371508746153134   20.769375301115637
1.371508746669684   20.063715232649155
1.371508763194999   5.048020735228436
1.371508766031260   4.141215569327951
};
    \end{axis}
\end{tikzpicture} 
\end{document}

答案1

即使使用 fpu 格式,这也不起作用。转换后请参见警告pgfplots

\documentclass{beamer}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}

\begin{tikzpicture}
\pgfkeys{/pgf/fpu}
\pgfmathfloatparsenumber{1.371508664312009}\xdef\myxmin{\pgfmathresult}
\pgfmathfloatparsenumber{1.371508780212562}\xdef\myxmax{\pgfmathresult}
\pgfkeys{/pgf/fpu=false}
    \begin{axis}[,
        cycle list={%
            {black}
        },enlargelimits=false,
        xmin = \myxmin,
        xmax = \myxmax,
        ]
        \addplot[unbounded coords=discard] table[x=k,y=F_k] {
k                   F_k
1.371508647597729   4.218629299064943
1.371508655954869   4.367306455608867
1.371508664312009   4.546736697704027
1.371508672669148   4.767650229729832
1.371508710724181   7.117825185499241
1.371508713560441   7.513271582940213
1.371508716396702   7.985684237353307
1.371508719232962   8.552417433810986
1.371508722069223   9.245525102110591
1.371508724905483   10.115770661107760
1.371508727741744   11.225899722988125
1.371508730578004   12.667837277184283
1.371508737113507   17.998622084719759
1.371508738663157   19.703601372911169
1.371508739179707   20.274665134457187
1.371508739696257   20.825915113218606
1.371508742279008   22.855385665696630
1.371508742795558   22.988513291704997
1.371508745120034   21.959402178915621
1.371508745636584   21.414072973829519
1.371508746153134   20.769375301115637
1.371508746669684   20.063715232649155
1.371508763194999   5.048020735228436
1.371508766031260   4.141215569327951
};
    \end{axis}
\end{tikzpicture} 

\end{document}

并且日志文件有警告:

包 pgfplots 警告:x 轴的轴范围几乎为空;在输入行 46 上将其扩大(它是 [1.3715086000000000:1.371508 8000000000])。

[警告/pgfplots/warning/大约空范围扩大]

如果您确实需要这种精度,请去掉常数部分,然后取数据的对数并绘制该对数。实际上,如果没有专用的 small int、big int 库,这种方法在任何语言中都无法正常工作。

相关内容