我正在尝试使用 pgfplots 包绘制图表。我的代码如下
\begin{tikzpicture}
\begin{axis}[
xlabel={ Time (seconds)},
ylabel={Exp},
xmin=0, xmax=18,
ymin=0, ymax=2000000,
xtick={0, 4, 8, 12, 16, 18},
ytick={0, 200, 2000, 20000, 200000, 2000000},
legend pos=north west,
ymajorgrids=true,
grid style=dashed,
]
\addplot[
color=black,
mark=square,
]
coordinates {
(8.718, 1056785)
};
\end{axis}
\end{tikzpicture}
问题出在 y 轴上,如下图所示。
我想显示区间 {0, 200, 2000, 20000, 200000, 2000000},但所有内容都按 10^6 缩放。你能帮助我吗?
答案1
使用对数刻度作为纵轴
\documentclass[border = 4pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel={Time (seconds)},
ylabel={Exp},
xmin=0, xmax=18,
ymin=2, ymax=2000000,
xtick={0, 4, 8, 12, 16, 18},
ytick={2, 20, 200, 2000, 20000, 200000, 2000000},
legend pos=north west,
ymajorgrids=true,
grid style=dashed,
ymode=log,
log ticks with fixed point,
]
\addplot[
color=black,
mark=square,
]
coordinates {
(8.718, 1056785)
};
\end{axis}
\end{tikzpicture}
\end{document}