![Pgfplot 将 x 域限制为 y。图看起来很奇怪](https://linux22.com/image/353475/Pgfplot%20%E5%B0%86%20x%20%E5%9F%9F%E9%99%90%E5%88%B6%E4%B8%BA%20y%E3%80%82%E5%9B%BE%E7%9C%8B%E8%B5%B7%E6%9D%A5%E5%BE%88%E5%A5%87%E6%80%AA.png)
我正在尝试绘制一个由小浮点数(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}