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.

This seems like it should be straightforward but I'm new to using pgfplots. I have been using this awesome box plot code and would like to be able to add a single point

How can I make:

\addplot[color = black, mark = *, nodes near coords,every node near coord/.style={anchor=180}]coordinates {( 0, -1)};

Label with a text label (say mylabel) rather than the value (-1) which is displayed?

The total code is (combined with box plotting code):

\begin{filecontents}{testdata.dat}
%x whiskerbottom boxbottom median boxtop whiskertop 
 0  -0.573413   -0.528268   -0.641948 -0.483655 -0.794368   
\end{filecontents}

\begin{tikzpicture}
\begin{axis} [
    xtick={0},
    xticklabels=test, 
    box plot width=10mm]

\boxplot [black]{testdata.dat}
%I've modified things to get to this point but cannot seem to figure out how to add a text label to it
\addplot[color = black, mark = *, nodes near coords,every node near coord/.style={anchor=180}]coordinates {( 0, -1)};

\end{axis}
\end{tikzpicture}
share|improve this question
1  
Could you please expand your code to a full minimal working example (MWE)? Simply adding a documentclass and the tikz and pgfplots package didn't do the trick. –  Benedikt Bauer Mar 29 '13 at 22:44

1 Answer 1

up vote 5 down vote accepted

You can set the contents of the nodes by using the optional argument to node near coords=<content>. By default, it's set to \pgfmathprintnumber{\pgfplotspointmeta}, but you can use any text or code. To use the static text mylabel, you'd say nodes near coords=mylabel:

\addplot [black, mark = *, nodes near coords=mylabel,every node near coord/.style={anchor=180}] coordinates {( 0, -1)};

share|improve this answer

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.