奇怪的行为 x 刻度标签样式与 y 刻度标签样式

奇怪的行为 x 刻度标签样式与 y 刻度标签样式

我用这段代码制作了一个图表:

    \documentclass[11pt,a4paper]{article} % use larger type; default would be 10pt
\usepackage{pgfplots}
\usepackage{tkz-euclide}


\begin{document}

\begin{tikzpicture}
\begin{axis}[%
major grid style=black,
axis lines=center,
ymin=0, ymax=0.202,
xmin=0, xmax=5.1,
xtick={0,1,...,5.1},
width=\linewidth,
height=10cm,
xlabel={$F_z(N)$},
ylabel={$\Delta l(m)$},
x tick label style={/pgf/number format/fixed, /pgf/number format/precision=1, /pgf/number format/fixed zerofill},
y tick label style={/pgf/number format/fixed, /pgf/number format/precision=3, /pgf/number format/fixed zerofill},
every axis x label/.style={at={(current axis.right of origin)},anchor=west},
every axis y label/.style={at={(current axis.north west)}, anchor=south},
minor xtick={0,0.1,...,5},
minor ytick={0,0.002,...,0.2},
grid=both,
]
\end{axis}
\end{tikzpicture}



\begin{center}
\begin{tikzpicture}
\begin{axis}[%
major grid style=black,
axis lines=center,
ymin=0,
ymax=25,
xmin=0, xmax=0.07,
x tick label style={/pgf/number format/fixed, /pgf/number format/precision=2, /pgf/number format/fixed zerofill},
ytick={0,5,...,25},
tick label style={font=\small},
width=\linewidth,
height=9cm,
xlabel={\small $m$ (kg)},
ylabel={\small $Q$ (kJ)},
%ticks=both,
%minor xtick={0,5,...,40},
minor ytick={0,1,...,25},
grid=both,
ylabel near ticks,
xlabel near ticks,
]
\addplot[very thick, domain=0:1, no markers,samples=3] {250*x}; 
\addplot[color = black, fill  = black, mark  = *,  only marks] coordinates{(0.005,3)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

第一个图表有正确的刻度,但我想在 x 轴上为第二个图表重复此操作,但它给出了 .10^-2,我不想要这个符号。我做错了什么?

在此处输入图片描述

答案1

你没有做错什么。这是代码的预期输出。如果你不想缩放刻度,可以通过添加到第二张图或序言中来关闭它,或者通过更改键和/或scaled ticks=false的值来更改数字应缩放的范围。scale ticks below exponentscale ticks above exponent

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        scaled ticks=false,             % <-- turn scaling off
%        % when scaling is on
%        scale ticks below exponent=-1,
%        scale ticks above exponent=3,
    }
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
      major grid style=black,
      axis lines=center,
      ymin=0, ymax=0.202,
      xmin=0, xmax=5.1,
      xtick={0,1,...,5.1},
      width=\linewidth,
      height=10cm,
      xlabel={$F_z(N)$},
      ylabel={$\Delta l(m)$},
      x tick label style={
        /pgf/number format/fixed,
        /pgf/number format/precision=1,
        /pgf/number format/fixed zerofill,
      },
      y tick label style={
        /pgf/number format/fixed,
        /pgf/number format/precision=3,
        /pgf/number format/fixed zerofill,
      },
      every axis x label/.style={
        at={(current axis.right of origin)},
        anchor=west,
      },
      every axis y label/.style={
        at={(current axis.north west)},
        anchor=south,
      },
      minor xtick={0,0.1,...,5},
      minor ytick={0,0.002,...,0.2},
      grid=both,
    ]
  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
  \begin{axis}[
      major grid style=black,
      axis lines=center,
      ymin=0,
      ymax=25,
      xmin=0, xmax=0.07,
      x tick label style={
        /pgf/number format/fixed,
        /pgf/number format/precision=2,
        /pgf/number format/fixed zerofill,
      },
      ytick={0,5,...,25},
      tick label style={font=\small},
      width=\linewidth,
      height=9cm,
      xlabel={\small $m$ (kg)},
      ylabel={\small $Q$ (kJ)},
      %ticks=both,
      %minor xtick={0,5,...,40},
      minor ytick={0,1,...,25},
      grid=both,
      ylabel near ticks,
      xlabel near ticks,
    ]
    \addplot[very thick, domain=0:1,no markers,samples=3] {250*x};
    \addplot[color=black,fill=black, mark=*,only marks] coordinates{(0.005,3)};
  \end{axis}
\end{tikzpicture}
\end{document}

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

相关内容