# “Node near coord” at the bottom of bar plots, but with symbolic coordinates

I need to place the "node near coords" below the bars of a bar plot instead of above, similarly to this question, but with a difference.

\documentclass{report}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
ymin=0, yticklabel style={/pgf/number format/fixed},
visualization depends on=y \as \rawy,
symbolic x coords={a,b,c,d}, enlarge x limits=0.15,
every node near coord/.append style={
font=\tiny,
shift={(axis direction cs:0,-\rawy)}
}
]
\addplot+ [nodes near coords, point meta=explicit symbolic]
table[x index=0, y index=1, meta index=3] {
a   0.1872  0.0040  0
b   0.0358  0.0017  22
c   0.0358  0.0017  23
d   0.0358  0.0017  24
};
\end{axis}
\end{tikzpicture}
\end{document}


The above snippet is exactly reported from this answer to that question, but with symbolic coordinates instead of numeric. Hence, the 0 in the shift x coordinate is wrong, and I get the following error:

! Package pgfplots Error: Sorry, the input coordinate 0' has not been defined
with 'symbolic x coords={a,b,c,d}... Maybe it has been misspelled? Or did you m
ean something like [normalized]0?.


I tried to mess with visualization depends on but without success. Is there a way to make this solution work with symbolic x coordinates?

Simplest would be to use numbers for the x axis again by stating x expr=\coordindex which would directly work. To still have the "symbolic labels" just state them as xticklabels. (If you would have a file with the data it would even be simpler to "sync" the labels by using xticklabels from table.)

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
ymin=0,
xticklabels={a,b,c,d},      % <-- changed
yticklabel style={/pgf/number format/fixed},
visualization depends on=y \as \rawy,
enlarge x limits=0.15,
every node near coord/.append style={
font=\tiny,
shift={(axis direction cs:0,-\rawy)}
},
nodes near coords,
point meta=explicit,        % <-- (changed)
]
x expr=\coordindex,     % <-- changed
y index=1,
meta index=3,
] {
a   0.1872  0.0040  0
b   0.0358  0.0017  22
c   0.0358  0.0017  23
d   0.0358  0.0017  24
};
\end{axis}
\end{tikzpicture}
\end{document}
`

• works percectly! – gigabytes Jun 27 '19 at 7:58