如何防止跳跃 xtic 标签?

如何防止跳跃 xtic 标签?

这将说明含义。如何获取基线上的所有 xlabel?

\documentclass{standalone}

\pgfplotsset{compat=1.12}

\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=-0.1:0.1,yticklabel style={scaled ticks=false,
                             /pgf/number format/fixed,
                             /pgf/number format/precision=3},
yticklabel={%
\pgfmathprintnumberto[verbatim,fixed,precision=3]{\tick\possiblytrimmedtick%
\pgfmathparse{\possiblytrimmedtick == \tick ? int(1):int(0)}%
\ifnum\pgfmathresult>0\relax$\tick$\else\fi%
}
]
\addplot+ { x^3 };
\end{axis}
\end{tikzpicture}
\end{document}

非常感谢。JT

答案1

您可以typeset ticklabels with strutaxis环境设置选项:

\documentclass{standalone}
\usepackage{pgfplots}% <- missing package added
\pgfplotsset{compat=1.12}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
  domain=-0.1:0.1,
  yticklabel style={
    scaled ticks=false,
    /pgf/number format/fixed,
    /pgf/number format/precision=3
  },
  yticklabel={%
    \pgfmathprintnumberto[verbatim,fixed,precision=3]{\tick}\possiblytrimmedtick% <- missing } added
    \pgfmathparse{\possiblytrimmedtick == \tick ? int(1):int(0)}%
    \ifnum\pgfmathresult>0\relax$\tick$\else\fi%
  },
  typeset ticklabels with strut% <- added
]
\addplot+ { x^3 };
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容