![tikzpicture 中轴刻度的方向](https://linux22.com/image/391657/tikzpicture%20%E4%B8%AD%E8%BD%B4%E5%88%BB%E5%BA%A6%E7%9A%84%E6%96%B9%E5%90%91.png)
使用以下示例绘制条形图时,y 轴的刻度指向内部,x 轴的刻度指向外部。如何才能使它们都显示在图表的内部和外部?
\documentclass{standalone}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.16}
\begin{tikzpicture}
\begin{axis}[ybar,symbolic x coords={A,B,C},xtick={A,B,C}]
\addplot coordinates{(A,24)(B,25)(C,26)};
\addplot coordinates{(A,17)(B,19)(C,21)};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
从https://tex.stackexchange.com/a/140937/3929,另外还查找了选项xtick align
并猜测还有一个可以同时设置两者的选项。
\documentclass{standalone}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
symbolic x coords={A,B,C},
xtick={A,B,C},
tick align=center, % <------
]
\addplot coordinates{(A,24)(B,25)(C,26) };
\addplot coordinates{(A,17)(B,19)(C,21)};
\end{axis}
\end{tikzpicture}
\end{document}