缩放刻度选项不起作用

缩放刻度选项不起作用

我正在尝试使用 绘制一些时间序列数据pgfplots。我不想使用任何“刻度缩放”(即我的轴的科学符号)。我尝试了scaled ticksscaled y ticks选项,将它们设置为false。然而,这仍然会产生

有问题的轴线

我希望它说-0,050,05

这是我的示例代码:

\documentclass{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepgfplotslibrary{dateplot}
\pgfkeys{/pgf/number format/.cd,
       use comma}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[grid = both, date coordinates in = x,
    scaled ticks = false,
    no marks,
    xticklabel={\year},
    xlabel = {Year},
    ylabel = {Log-Return},
    ytick = {-0.1, -0.05, 0, 0.05, 0.1},
    ]
    \addplot[color = red] coordinates {
(2008-10-02,-0.0254135424025996)
(2008-10-03,0.0238105075745132)
(2008-10-06,-0.0733552237671908)
(2008-10-07,-0.011271710502907)
(2008-10-08,-0.0605605136703957)
(2008-10-09,-0.0255796141182998)
(2008-10-10,-0.072702704381916)
(2008-10-13,0.107974680453472)
(2008-10-14,0.0266522385158314)
(2008-10-15,-0.0671290843134731)
(2008-10-16,-0.0503709904911815)
(2008-10-17,0.0337160087215764)
(2008-10-20,0.0111643819661129)
(2008-10-21,-0.0105204008353059)
(2008-10-22,-0.0456154732581222)
(2008-10-23,-0.0113016115605298)
(2008-10-24,-0.0508381426486686)
(2008-10-27,0.00903107295142114)
(2008-10-28,0.10685088667814)
(2008-10-29,-0.003064794603306)
};
  \end{axis}
\end{tikzpicture}
\end{document}

答案1

scaled ticks将在轴的末端放置一个命令刻度。您需要fixed数字格式选项。

用于fixed

\pgfkeys{/pgf/number format/.cd,fixed,
      use comma}

完整代码:

\documentclass{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepgfplotslibrary{dateplot}
\pgfkeys{/pgf/number format/.cd,fixed,
       use comma}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[grid = both, date coordinates in = x,
    scaled ticks = false,
    no marks,
    xticklabel={\year},
    xlabel = {Year},
    ylabel = {Log-Return},
    ytick = {-0.1, -0.05, 0, 0.05, 0.1},
    ]
    \addplot[color = red] coordinates {
(2008-10-02,-0.0254135424025996)
(2008-10-03,0.0238105075745132)
(2008-10-06,-0.0733552237671908)
(2008-10-07,-0.011271710502907)
(2008-10-08,-0.0605605136703957)
(2008-10-09,-0.0255796141182998)
(2008-10-10,-0.072702704381916)
(2008-10-13,0.107974680453472)
(2008-10-14,0.0266522385158314)
(2008-10-15,-0.0671290843134731)
(2008-10-16,-0.0503709904911815)
(2008-10-17,0.0337160087215764)
(2008-10-20,0.0111643819661129)
(2008-10-21,-0.0105204008353059)
(2008-10-22,-0.0456154732581222)
(2008-10-23,-0.0113016115605298)
(2008-10-24,-0.0508381426486686)
(2008-10-27,0.00903107295142114)
(2008-10-28,0.10685088667814)
(2008-10-29,-0.003064794603306)
};
  \end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容