我的图表的 y 轴使用 0,005 这样的小数字。我不想使用默认出现的乘数,如 10^-3。如果我用
scaled x ticks = false, x tick label style={/pgf/number format/fixed},
刻度标签不够准确,仅显示 0 或 0,1:
使用的代码:
\begin{tikzpicture}
\begin{axis}[%
scaled x ticks = false,
x tick label style={/pgf/number format/fixed},
scaled y ticks = false,
scale only axis,
width=6cm,
height=5cm,
xmin=0, xmax=30000,
ymin=-0.001, ymax=0.006,
ymajorgrids,
axis on top]
我怎样才能解决这个问题?
答案1
尝试添加
yticklabel style={/pgf/number format/fixed,
/pgf/number format/precision=3}
作为 的一个选项axis
。
左有/pgf/number format/precision=3
,右无。完整代码:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
scaled x ticks = false,
x tick label style={/pgf/number format/fixed},
scaled y ticks = false,
yticklabel style={/pgf/number format/fixed,
/pgf/number format/precision=3},
scale only axis,
width=6cm,
height=5cm,
ymajorgrids,
axis on top]
\addplot coordinates {(0,0) (0.2,0.01)};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[%
scaled x ticks = false,
x tick label style={/pgf/number format/fixed},
scaled y ticks = false,
yticklabel style={/pgf/number format/fixed},
scale only axis,
width=6cm,
height=5cm,
ymajorgrids,
axis on top]
\addplot coordinates {(0,0) (0.2,0.01)};
\end{axis}
\end{tikzpicture}
\end{document}