Pgfplot 將 x 域限制為 y 域。劇情看起來怪怪的

Pgfplot 將 x 域限制為 y 域。劇情看起來怪怪的

我正在嘗試針對一組大整數(100:100000)繪製小浮點數(0:0.12)的基本二維圖,如下所示:

\begin{tikzpicture}
\begin{axis}[
    domain=100:100000,
    title={Request time dependence on database record size},
    xlabel={Database Size [number of records]},
    ylabel={Time [seconds per average of 1000 requests]},
    xmin=100, xmax=1000000,
    ymin=0, ymax=0.13,
    xtick={100, 1000, 10000, 100000},
    ytick={0,0.0001,0.001,0.01, 0.1},
    legend pos=north west,
    grid style=dashed,
    restrict y to domain=0:1
]

\addplot[
    color=blue,
    mark=square,
    ]
    coordinates {
    (100,0.0004)(1000,0.002519528)(10000,0.0134010380006657)(100000,0.125218412)
    };
    \legend{CuSO$_4\cdot$5H$_2$O}

\end{axis}
\end{tikzpicture}

然而,該圖看起來不正常(忽略圖例): 在此輸入影像描述

關於如何使 X 軸實際具有所需值的任何想法? (100、1000、10000、100000)

謝謝

答案1

而不是僅僅將 x 軸更改為對數模式(如 Torbjørn T. 在在問題下方評論)我建議對兩個軸都使用日誌模式。除此之外,您還有一些選項可以阻止圖表顯示,這就是我評論它們的原因。

% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.3}
\begin{document}
\begin{tikzpicture}
    \begin{loglogaxis}[
%        domain=100:100000,
        title={Request time dependence on database record size},
        xlabel={Database Size [number of records]},
        ylabel={Time [seconds per average of 1000 requests]},
        xmin=100, xmax=1000000,
        ymin=0, ymax=0.13,
%        xtick={100, 1000, 10000, 100000},
%        ytick={0,0.0001,0.001,0.01, 0.1},
        legend pos=north west,
%        grid style=dashed,
%        restrict y to domain=0:1,
    ]
        \addplot[
            color=blue,
            mark=square,
        ] coordinates {
            (100,0.0004)
            (1000,0.002519528)
            (10000,0.0134010380006657)
            (100000,0.125218412)
        };
        \legend{CuSO$_4\cdot$5H$_2$O}
    \end{loglogaxis}
\end{tikzpicture}
\end{document}

顯示上述程式碼結果的圖像

相關內容