Is is possible to rotate text using nodes near coords?
You can rotate the nodes using
every node near coord/.append style={rotate=90, anchor=west}
Note that this option needs to be added after ybar
, since ybar
overwrites the every node near coord
style.
The nodes near coords
do not automatically enlarge the plot area to accommodate them, so you have to do something like enlarge y limits={upper,value=0.2}
to adjust the top border of the plot area.
(Unrequested extra information: The option area legend
has to be passed to the addplots
, it is not an axis
option. To do this for all plots, you have to use the axis
option every axis plot post/.style={area legend}
)
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={D,F,R,M,K,S,C},
major tick length=0cm,
xtick=data,
enlarge y limits={upper,value=0.2},
nodes near coords,
ybar,
every node near coord/.append style={rotate=90, anchor=west},
bar width = 6pt,
]
\addplot
coordinates {(D,0.78) (F,0.23) (R,0.93) (M,0.73) (K,0.00) (S,0.37) (C,0.36)};
\addplot
coordinates {(D,0.52) (F,0.62) (R,0.60) (M,0.56) (K,0.64) (S,0.166) (C,0.170)};
\addplot
coordinates {(D,0.635) (F,0.437) (R,0.744) (M,0.345) (K,0.48) (S,0.652) (C,0.955)};
\end{axis}
\end{tikzpicture}
\end{document}