# Symbolic Labels in pgfplots Bar Chart

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},
]
(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}


You can do it if you read the coordinates from a table:

## Code

\documentclass[tikz, border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepackage{pgfplotstable}
\usepackage{amsmath}

sym y
a 4.2
b 4.2
c 3.9
d 4.0
e 4.1
f 4.0
g 4.0
}\mypoints

\begin{document}

\begin{tikzpicture}
\begin{axis}
[   axis y line=left,
axis x line=middle,
enlargelimits=0.15,
ylabel={$\frac{\text{Score}}{5}$},
ymin = 0,
ymax = 5,
ybar,
xticklabels from table={\mypoints}{sym},
xtick=data,
]

• Adding something like xticklabel style={text height=1.5ex} or xticklabel style={font=\strut} should fix that. Oct 31 '15 at 8:16