Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

1 Answer

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
]
\addplot table [meta index=2] {data.dat};
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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