In the following code, why do I have to type the x-axis labels explicitly in the axis
options and not just use the labels from the coordinates
data? Is there a way to just use the data from the coordinates
? This wold be really inconvenient specially for large data sets..
\documentclass{article}
\usepacage{pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
width=12cm,
height=5cm,
ybar,
axis y line=left,
axis x line=middle,
enlargelimits=0.15,
ylabel={Score/5},
ymin = 0,
ymax = 5,
symbolic x coords={a,b,c,d,%
e,f,g,h},
xtick=data,
nodes near coords align={vertical},
x tick label style={rotate=90,anchor=east},
]
\addplot[fill=maroon!30] coordinates { (f2011,4.1)
(a,4.2) (b,4.2) (c,3.9)
(d,4.0) (e,4.1) (f,4.0)
(g,4.0) };
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
Best Answer
You can do it if you read the coordinates from a table:
Code
Output