I am making bar plots (xbar) in pgfplots and adding text/numbers on top of each bar by using the nodes near coords command in the axis environment. The x-axis is by purpose not given any value for the parameter xmax in order to make the tallest bar dynamically determine the maximum x-value used in the axis (the line xmax=100 is commented out). However, the extent of the text/numbers on top of each bar is not taken into account when the max value along the x-axis is determined by TikZ. In my example, the name "Steve" on top of the second bar from above is overlapping with the right y-axis. How do I prevent this in a way that will fix the problem independently of the x values in the data.dat file?
\documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}
\pgfplotsset{compat=newest}
\begin{filecontents}{data.dat}
Age-interval Y-Position Score Name
20-30 1 15 Peter
30-40 2 98 Jeff
40-50 3 121 Steve
50-60 4 24 John
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\makeatletter
\begin{axis}[
xlabel={Test score},
xbar,
bar width=2pt,
ytick=data,
width=8 cm,
height=5 cm,
xmin=-1,
% xmax = 100,
xticklabel pos = upper,
tick align = outside,
yticklabel pos=left,
yticklabels from table={data.dat}{Age-interval},
ylabel={Age intervals (yr)},
nodes near coords,
every node near coord/.append style={anchor=west},
point meta=explicit symbolic
]
\addplot table [
y=Y-Position,
x=Score,
meta=Name
] {data.dat};
\end{axis}
\end{tikzpicture}
\end{document}


