バー全体を表示し、y 軸を両方向 (上と下) にわずかに拡張するにはどうすればよいですか?
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar,
xmin = 0,
y = 35pt,
bar width= 2em,
axis x line = none,
axis y line = left,
tickwidth = 0pt,
symbolic y coords = {A,B,C,D},
nodes near coords,
]
\addplot coordinates { (45,A) (55,B) (40,C) (50,D) };
\end{axis}
\end{tikzpicture}
\end{document}
答え1
はい。 で y 制限を拡大できますenlarge y limits
。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar,
xmin = 0,
y = 35pt,
bar width= 2em,
axis x line = none,
axis y line = left,
tickwidth = 0pt,
symbolic y coords = {A,B,C,D},
nodes near coords,enlarge y limits=0.2
]
\addplot coordinates { (45,A) (55,B) (40,C) (50,D) };
\end{axis}
\end{tikzpicture}
\end{document}