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?


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$.

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

    nodes near coords=$\pgfplotspointmeta$,
    point meta=explicit symbolic
\addplot table [meta index=2] {data.dat};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.