# Use text data as mark labels in pgfplots

I have a table with numerical data and text in different columns, like this:

0   0   0.1
1   0   \pi
2   0   \frac{\pi}{2}


I'd like to put text labels on a plot using the text in the third column at the position given by the first two columns (I need to overlay these text labels on a plot at given positions). Is it possible with pgfplots?

-
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. –  Joseph Wright Apr 27 '12 at 11:39

Yes, that is possible. You'll need to tell pgfplots to expect symbolic meta data (so it doesn't try to parse it as numbers), which you do using the key point meta=explicit symbolic.

Since you're using math commands in your labels, you'll have to make sure they are typeset in math mode. You can do this using nodes near coords=$\pgfplotspointmeta$.

\documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{filecontents}{data.dat}
0   0   0.1
1   0   \pi
2   0   \frac{\pi}{2}
\end{filecontents}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
nodes near coords=$\pgfplotspointmeta$,
point meta=explicit symbolic
]