Pgfplot 将 x 域限制为 y。图看起来很奇怪

Pgfplot 将 x 域限制为 y。图看起来很奇怪

我正在尝试绘制一个由小浮点数(0:0.12)和一组大整数(100:100000)组成的基本二维图,如下所示:

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

该图显示了上述代码的结果

相关内容