如何讓xmin和xmax在小區間內運作?

如何讓xmin和xmax在小區間內運作?

以下使用以 x = 0 和 x = 2 為界的龐大資料集的小樣本。但這不適用於以下程式碼。怎麼了? (我顯然可以縮放結果,但我想要一個更通用的解決方案,因為這種情況在我的論文中經常發生)

\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/警告/近似空範圍擴大]

如果您確實需要這種精確度,請去掉常數部分,然後記錄資料並繪製出來。實際上,如果沒有專用的小整型、大整數函式庫,這實際上無法在任何語言中正常運作。

相關內容