4

I plot some points in pgfplots like in the following MWE:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}

\begin{document}

\begin{tikzpicture}
 \begin{axis}[
  axis x line=bottom,
  axis y line=left,
  xmin=0, xmax=2.5,
  ymin=0, ymax=2.5,
  xtick=\empty,
  ytick=\empty,
  xlabel=position $x$,
  ylabel=time $t$
  ]

  \addplot [only marks] table {
   0.5 1
   1.5 1
   0.5 2
   1.5 2
  };

  \addplot [only marks, mark=o] table {
   1 0.5
   2 0.5
   1 1.5
   2 1.5
  };
 \end{axis}
\end{tikzpicture}

\end{document}

This gives me the following result:

result of MWE

Now I would like to add a label next to each point. The result should look like this:

desired result

How can I do that?

2
  • are the labels also in the file or sequential letters?
    – percusse
    Commented Sep 1, 2015 at 11:08
  • I'd like to specify the labels seperatetely for each point, e.g. as a third colum in the tables.
    – Blub Bla
    Commented Sep 1, 2015 at 11:17

1 Answer 1

6

Here is one example

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}

\begin{tikzpicture}
 \begin{axis}[
  axis x line=bottom,
  axis y line=left,
  xmin=0, xmax=2.5,
  ymin=0, ymax=2.5,
  xtick=\empty,
  ytick=\empty,
  xlabel=position $x$,
  ylabel=time $t$,
  ]

  \addplot [only marks,mark=*,nodes near coords={\labelz},
             visualization depends on={value \thisrowno{2}\as\labelz}] 
  table[header=false] {
   0.5 1 a
   1.5 1 f
   0.5 2 g
   1.5 2 z
  };

 \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .