Related question (among others): Generic point labels in pgfplots
I wish to set the labels of points in my graph to some given string values (ideally defined by a previous macro). Apparently there are tricks involving the point meta key but if I understand correctly those can only be set to numerical values.
The following returns the labels "Point number 1", "Point number 2", etc. i.e. text expressions but that is limited to expressions that one can evaluate from the \coordindex macro.
Note that a \newcommand{\mynames} such that \mynames{1} expands to "First", \mynames{2} to "Second", etc. should be sufficient but I do not know how to code that.
\documentclass{standalone}
\usepackage{pgfplots}
%\pgfplotsset{compat = 1.14}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\newcommand{\samplepoints}{0,2,4}
\addplot[samples at={\samplepoints},
nodes near coords={\pgfmathtruncatemacro\nValue{\coordindex+1} Point number \nValue},
% nodes near coords/.expanded={First, Second, Third}, % I wish this worked
] {x^2};
\end{axis}
\end{tikzpicture}
\end{document}

3 {}– Christian Feuersänger Oct 23 '16 at 13:01