Given some data (from a file), I would like to use the first two columns as coordinates, and the last column as label for every point.
x y label
123 5.2 name
I use the table command to read the first two columns as data:
\begin{tikzpicture}
\begin{axis}
\addplot+[only marks,x=x, y=y, ] table {Data.dat};
\end{axis}
\end{tikzpicture}
The data of the second column should appear above each scatter point as simple text.
A promising option seems to be the option nodes near coords, but I don't see how I can use the data from the file and combine it with that.
This question is similar to this post, where they had numerical values in the last column.
Best Answer
nodes near coords
prints themeta
value for each data point, which defaults to they
coordinate. To print something else, you have to define what themeta
value is. In your case, you want to provide themeta
value explicitly for each data point (and not calculate it or use a constant value, say), so you have to setpoint meta=explicit symbolic
(thesymbolic
tells PGFPlots not to pass the value through the number parser). Then you can setmeta=name
in the\addplot table [...]
options to specify that themeta
value should be taken from thename
column.