更改 y 轴上的数字精度

更改 y 轴上的数字精度

当我尝试绘制这个图时:

  \begin{tikzpicture}
  \begin{axis}[%
  scale=1.5,
  max space between ticks=25, 
  ticklabel style={font=\scriptsize},
  axis lines = middle,
  xmin=-8000, xmax=9000, 
  ymin=-10000, ymax=130000, 
  domain=-8000:9000,         
  grid=both,
  xlabel=$ q $, ylabel=$ R\ C $,
  yticklabel style={
  /pgf/number format/fixed,
  /pgf/number format/fixed zerofill}]
  \path [pattern color=yellow, pattern=north west lines] (axis cs:8000,-10000) -- (axis cs:8000,130000) -- (axis cs:9000,130000) -- (axis cs:9000,-10000) -- (axis cs:8000,-10000);
  \addplot [very thick, blue, smooth] {15*x};
  \addplot [very thick, green, smooth] {5*x+30000};
  \draw [fill=red](axis cs:0,0) circle (2.5pt);
  \draw [fill=red](axis cs:8000,120000) circle (2.5pt);
  \draw [fill=yellow](axis cs:3000,45000) circle (2.5pt) node [below right] {$B.E.P. (3000,45000)$};
  \draw [fill=red](axis cs:0,30000) circle (2.5pt);
  \draw [fill=red](axis cs:-6000,0) circle (2.5pt);
  \draw [thick, red, dashed] (axis cs:8000,130000) -- (axis cs:8000,-10000);
\end{axis}
\end{tikzpicture}

我得到这个图表: 在此处输入图片描述

y 轴上有科学记数法,但我不需要它。我该如何避免这种缺失?

答案1

使用

  scaled y ticks=false,
  yticklabel style=/pgf/number format/fixed,

在此处输入图片描述

代码:

\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{patterns}
\pgfplotsset{compat=1.12}
\begin{document}
  \begin{tikzpicture}
  \begin{axis}[%
  scale=1.5,
  max space between ticks=25, 
  ticklabel style={font=\scriptsize},
  axis lines = middle,
  xmin=-8000, xmax=9000, 
  ymin=-10000, ymax=130000, 
  domain=-8000:9000,         
  grid=both,
  xlabel=$ q $, ylabel=$ R\ C $,
  scaled y ticks=false,
  yticklabel style=/pgf/number format/fixed,
  ]
  \path [pattern color=yellow, pattern=north west lines] (axis cs:8000,-10000) -- (axis cs:8000,130000) -- (axis cs:9000,130000) -- (axis cs:9000,-10000) -- (axis cs:8000,-10000);
  \addplot [very thick, blue, smooth] {15*x};
  \addplot [very thick, green, smooth] {5*x+30000};
  \draw [fill=red](axis cs:0,0) circle (2.5pt);
  \draw [fill=red](axis cs:8000,120000) circle (2.5pt);
  \draw [fill=yellow](axis cs:3000,45000) circle (2.5pt) node [below right] {$B.E.P. (3000,45000)$};
  \draw [fill=red](axis cs:0,30000) circle (2.5pt);
  \draw [fill=red](axis cs:-6000,0) circle (2.5pt);
  \draw [thick, red, dashed] (axis cs:8000,130000) -- (axis cs:8000,-10000);
\end{axis}
\end{tikzpicture}
\end{document}

答案2

非常有用,我还添加了这个:

 yticklabel style={/pgf/number format/fixed,
 /pgf/number format/set thousands separator={\,}}]

因为我觉得它对我来说更可靠。

相关内容