\documentclass[border=2pt]{standalone}
\usepackage{pgfplots,tikz}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={Germany,Spain,UK},
xtick={Germany,Spain,UK},
xticklabels={\bfseries\textcolor{green}{Germany},Spain,UK},
axis x line=bottom,
axis y line=left,
x tick label style={rotate=45},
ymin=0,
enlarge x limits={abs=0.5cm},
ymax=110,
ytick={0,10,...,100},
ybar=6pt,
bar width=14pt,
nodes near coords,
ylabel=\% blablabla
]
\addplot[bar shift=0pt,fill=blue] coordinates {
(Germany,10)
};
\addplot[bar shift=0pt,fill=red] coordinates {
(Spain,30)
};
\addplot[bar shift=0pt,fill=yellow] coordinates {
(UK,40)
};
\end{axis}
\end{tikzpicture}
\end{document}
我希望坐标“10”附近的节点为绿色并以粗体显示,就像“德国”坐标一样。这可能吗?
答案1
放入every node near coord/.style={text=green,font=\boldmath}
\addplot[bar shift=0pt,fill=blue,every node near coord/.style={text=green,font=\boldmath}] coordinates {
(Germany,10)
};