I am trying to adapt the setup to be found in this question. to the case where the names are in a different file. The main motivation is to have the same names for several plots and to be able to change them without altering the data files.
I tried to use the method to add a column from this question and produces the code below. I get the following error:
! Missing $ inserted.
<inserted text>
$
which I fail to interpret. How can it be done?
\begin{tikzpicture}
\pgfplotstableset{
create on use/names/.style={
create col/copy column from table={names.dat}{names}
}
}
\begin{axis}[
visualization depends on={value \thisrow{names} \as \labela},
nodes near coords={\labela},
]
\addplot[scatter,only marks] table [x expr=\thisrowno{0},y expr=\thisrowno{1}] {data.dat};
\end{axis}
\end{tikzpicture}
data.dat:
1 1
2 4
3 7
names.dat:
Xyzzy
Plugh
Sheng