使用以下示例绘制条形图时,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}