pgfplots - 以科学计数法改变幂

pgfplots - 以科学计数法改变幂

对于 xtick 标签,当我输入 0.002 时,它在轴上显示为 0.2 x 10^{-2},而我希望它显示为 2 x 10^{-3}。尝试更改精度,但只会更改尾随零。如何控制它?

这是我正在运行的代码:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}

\begin{document}

\begin{tikzpicture}[scale=1,baseline]

\begin{axis}[
     y tick label style={
        /pgf/number format/.cd,
            fixed,
            fixed zerofill,
            precision=1,
        /tikz/.cd
    },

    x tick label style={
        /pgf/number format/.cd,
            fixed,
            fixed zerofill,
            precision=1,
        /tikz/.cd
    },
     xmin=0, xmax=0.01,
     ymin=0.5, ymax=1,
     yticklabel style = {font=\normalsize} ]

     \addplot[color=red, mark=o, thick, fill=none] coordinates{
  (0,1)
  (0.002,0.8)
  (0.004,0.75)
  (0.006,0.7)
  (0.008,0.65)
  (0.01,0.6)
     };

\end{axis}


\end{tikzpicture}

\end{document}

答案1

您在寻找吗/pgf/number format/sci

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}

\begin{document}

\begin{tikzpicture}[scale=1,baseline]

\begin{axis}[
     y tick label style={
        /pgf/number format/.cd,
            fixed,
            fixed zerofill,
            precision=1,
        /tikz/.cd
    },
    x tick label style={
        /pgf/number format/.cd,
            fixed,
            fixed zerofill,
            precision=1,
            sci,
        /tikz/.cd
    },scaled x ticks=false,
     xmin=0, xmax=0.01,
     ymin=0.5, ymax=1,
     yticklabel style = {font=\normalsize} ]

     \addplot[color=red, mark=o, thick, fill=none] coordinates{
  (0,1)
  (0.002,0.8)
  (0.004,0.75)
  (0.006,0.7)
  (0.008,0.65)
  (0.01,0.6)
     };

\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

您随时可以采用 配置您自己的数字格式xticklabel

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}

\begin{document}

\begin{tikzpicture}[scale=1,baseline]

\begin{axis}[
     y tick label style={
        /pgf/number format/.cd,
            fixed,
            fixed zerofill,
            precision=1,
        /tikz/.cd
    },
    xticklabel={$\pgfmathparse{1000*\tick}%
      \pgfkeys{/pgf/number format/.cd,precision=0}\pgfmathprintnumber\pgfmathresult\cdot10^{-3}$%
    },scaled x ticks=false,
     xmin=0, xmax=0.01,
     ymin=0.5, ymax=1,
     yticklabel style = {font=\normalsize} ]

     \addplot[color=red, mark=o, thick, fill=none] coordinates{
  (0,1)
  (0.002,0.8)
  (0.004,0.75)
  (0.006,0.7)
  (0.008,0.65)
  (0.01,0.6)
     };

\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

这是使用 的另一种可能性scaled x ticks=manual

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}

\begin{document}

\begin{tikzpicture}[scale=1,baseline]

\begin{axis}[
     y tick label style={
        /pgf/number format/.cd,
            fixed,
            fixed zerofill,
            precision=1,
        /tikz/.cd
    },
    scaled x ticks=manual:{$\cdot10^3$}{\pgfmathparse{#1*1000}},
     xmin=0, xmax=0.01,
     ymin=0.5, ymax=1,
     yticklabel style = {font=\normalsize} ]

     \addplot[color=red, mark=o, thick, fill=none] coordinates{
  (0,1)
  (0.002,0.8)
  (0.004,0.75)
  (0.006,0.7)
  (0.008,0.65)
  (0.01,0.6)
     };

\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容