# tikzpicture plot error message

I am trying to create a plot with only a few points. But I get a lot of error messages like Undefined control sequence. \end{axis}

Can somebody explain me what is wrong in my code.

\documentclass[
12pt, % font size
a4paper, % paper format
oneside, % one-sided pages
]{article}

% Graph
\usepackage{pgfplots}

\begin{document}

\begin{figure}[!h]
\centering
\begin{tikzpicture}
\begin{axis}[
xlabel=Tragweite,
ylabel=Wahrscheinlichkeit,
xmin=0,
ymin=0,
xmax=11,
ymax=11
]
mark=*,
only marks,
point meta=explicit symbolic,
nodes near coords={
\labelcheck{\pgfplotspointmeta}
}
] table[meta=label] {
x   y   label
3   6   1
5   6   2
6   4   3
2   8   4
1   9   5
3   5   6
7   3   7
};
\end{axis}
\end{tikzpicture}
\caption{Risiken}
\label{fig:risiken}
\end{figure}

\end{document}

• \labelcheck is not a standard macro, its definition is missing. Presumably you got it from tex.stackexchange.com/questions/331784/…? – Torbjørn T. Oct 4 '17 at 11:19
• @TorbjørnT. yes I got it from there, I added the definition now, but now it does no longer show any labels. – Pascal Oct 4 '17 at 11:22
• No, the purpose of that macro is to show only a select set of labels, as defined by the \labelonly macro. (That is the point of the question, after all.) If you want all points labeled, just remove ={\labelcheck{\pgfplotspointmeta}} – Torbjørn T. Oct 4 '17 at 11:28
• I can add an answer, but before I do, please specify exactly what kind of output you expect. – Torbjørn T. Oct 4 '17 at 11:41
• @TorbjørnT. I think I just remove the labelcheck then it should work and the result is sufficient enough. Thanks for your help. – Pascal Oct 4 '17 at 11:42

The only uncommon thing in your code is the \labelcheck macro. This is not part of pgfplots, but defined by Symbol 1 in his answer to Labelling list of points in PGF scatter plot. So if you add the definition of \labelcheck (and \labelonly) from that answer your code works fine.

Now, the whole point of that macro is to only print the node near coord for specific labels (meta values), as defined by the \labelonly macro. Note in that code that the meta values are A through F, and that with \labelonly{BDF} only those three labels are shown. You have meta values 1 through 7, so with \labelonly{BDF} nothing is of course printed. Modify it to \labelonly{236} and those labels are printed.

As I understand it though, you want all the labels to be printed, so all of that stuff is unnecessary -- printing all the labels is the default. Hence, all you need to do is remove ={\labelcheck{\pgpflotspointmeta}}, and then you can remove the definition of \labelcheck as well.

\documentclass[
12pt, % font size
a4paper, % paper format
oneside, % one-sided pages
]{article}
\usepackage{pgfplots}

\begin{document}

\begin{figure}[!h]
\centering
\begin{tikzpicture}
\begin{axis}[
xlabel=Tragweite,
ylabel=Wahrscheinlichkeit,
xmin=0,
ymin=0,
xmax=11,
ymax=11
]
mark=*,
only marks,
point meta=explicit symbolic,
nodes near coords % removed the \labelcheck stuff
] table[meta=label] {
x   y   label
3   6   1
5   6   2
6   4   3
2   8   4
1   9   5
3   5   6
7   3   7
};
\end{axis}
\end{tikzpicture}
\caption{Risiken}
\label{fig:risiken}
\end{figure}

\end{document}