pgfplots:次要 xticklabels?

pgfplots:次要 xticklabels?

我想明确地设置小 x 刻度上的标签,但是这

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
xtick={-1.5,-1,-0.5, 0.0,0.5, 1.0,1.5},
xticklabels={$a$, $b$, $c$, $d$,$e$, $f$},
minor xtick={-0.7},
minor xticklabels={$z$}
]
\addplot[smooth,blue,mark=*]
coordinates {%
  (-1, 1)
  (-0.75, 0.5625)
  (-0.5, 0.25)
  (-0.25, 0.0625)
  (0, 0)
  (0.25, 0.0625)
  (0.5, 0.25)
  (0.75, 0.5625)
  (1, 1)
};
\end{axis}
\end{tikzpicture}
\end{document}

失败

! Package pgfkeys Error: I do not know the key '/tikz/minor xtick labels', to w
hich you passed '$z$', and I am going to ignore it. Perhaps you misspelled it.

有什么提示吗?

答案1

pgfplots我认为没有标记小刻度,但对于像你的例子这样的情况,它有以下概念extra x ticks

extra x ticks={-0.7},
extra x tick labels={$z$}

在此处输入图片描述

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
xtick={-1.5,-1,-0.5, 0.0,0.5, 1.0,1.5},
xticklabels={$a$, $b$, $c$, $d$,$e$, $f$},
extra x ticks={-0.7},
extra x tick labels={$z$}
]
\addplot[smooth,blue,mark=*]
coordinates {%
  (-1, 1)
  (-0.75, 0.5625)
  (-0.5, 0.25)
  (-0.25, 0.0625)
  (0, 0)
  (0.25, 0.0625)
  (0.5, 0.25)
  (0.75, 0.5625)
  (1, 1)
};
\end{axis}
\end{tikzpicture}
\end{document}

相关内容