[Tex/LaTex] Scatter plot with text labels and colors from table with pgfplots

pgfplotspgfplotstable

I want to scatter plot points from table with colors and text labels from table. Choosing colors works with classes but labels are parsed as numbers and appear as "nan".

Scatterplot with nan labels instead of text

\documentclass[tikz]{standalone}

\usepackage[utf8]{inputenc}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[enlargelimits=0.2]
    \addplot[
        scatter/classes={a={blue}, b={red}},
        scatter, mark=*, only marks, 
        scatter src=explicit symbolic,
        nodes near coords*={\label},
        visualization depends on=\thisrow{label} \as \label
    ] table [meta=class] {
        x y class label
        0.5 0.2 a A
        0.2 0.1 b B
        0.7 0.6 a C
        0.35 0.4 a D
        0.65 0.1 a E
    };
\end{axis}
\end{tikzpicture}

\end{document}

How do I stop pgfplots from parsing the labels?

Best Answer

Simply add "value".

\documentclass[tikz]{standalone}

\usepackage[utf8]{inputenc}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[enlargelimits=0.2]
    \addplot[
        scatter/classes={a={blue}, b={red}},
        scatter, mark=*, only marks, 
        scatter src=explicit symbolic,
        nodes near coords*={\Label},
        visualization depends on={value \thisrow{label} \as \Label} %<- added value
    ] table [meta=class] {
        x y class label
        0.5 0.2 a A
        0.2 0.1 b B
        0.7 0.6 a C
        0.35 0.4 a D
        0.65 0.1 a E
    };
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here