我有一个包含单条和多条的多条图:
我想将单条 A 和 D 置于中心;现在它们是左对齐的。
以下是代码:
\begin{tikzpicture}
\begin{axis}[
ybar, axis on top, height=8cm, width=8cm, bar width=0.6cm, ymajorgrids, tick align=inside,
major grid style={draw=white}, enlarge y limits={value=0.1,upper}, ymin=0, ymax=40,
axis x line*=bottom, axis y line*=left, y axis line style={opacity=0}, tickwidth=0pt,
enlarge x limits=true,
ylabel={Percentage (\%)},
ylabel style={align=center},
symbolic x coords={
A,B,C,D
},
xtick=data,
nodes near coords={
\pgfmathprintnumber[precision=1]{\pgfplotspointmeta}
},
x tick label style={font=\small,text width=2cm,align=center}
]
\addplot [draw=none, fill=blue!60] coordinates {
(A, 25.6)
(B, 10.3)
(C, 35.7)
(D, 22.4) };
\addplot [draw=none,fill=red!30,opacity=1] coordinates {
(B, 19.6)
(C, 26.1) };
\end{axis}
\end{tikzpicture}