[Tex/LaTex] Same color for mark and label in scatter plot

pgfplots

I would like to obtain a scatter plot with marks and labels of the same color.
I can get colored marks but labels stay stubbornly black:

I would like 0's to be blue, 1's to be green etc. in the plot above.

Here is my MWE:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{compat=1.12}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    xmin=0,
    xmax=1,
    ymin=0,
    ymax=1,
    axis equal image,
    hide axis,
]
\addplot [scatter, only marks, mark=x,
        point meta=explicit,
        nodes near coords*,
        every node near coord/.append style={font=\footnotesize}
    ] table [meta index=2] {points.dat};

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

And the points.dat file

0.399623458645 0.202770745691 1
0.43125083774 0.374183040618 1
0.267449590519 0.086101093226 1
0.498881452071 0.0733728461989 1
0.601248587386 0.607825227731 3
0.663964417031 0.767541727794 3
0.467522971487 0.734379206102 3
0.425463065344 0.554166354467 3
0.106015995305 0.761683705293 2
0.0695936622364 0.917923977313 2
0.0957757803902 0.602873159793 2
0.2631207767 0.484806666192 2
0.919353098154 0.52159970072 0
0.769039639969 0.408860920568 0
0.58319478496 0.256712040273 0
0.6020910719 0.44509904373 0

Best Answer

According to overleaf, this works

\documentclass{standalone}
\usepackage{pgfplots}

\pgfplotsset{compat=1.12}
\tikzset{adjust near node color/.code={%
    \pgfplotscolormapdefinemappedcolor\pgfplotspointmetatransformed%
    \definecolor{mapped node color}{rgb}{\pgfmathresult}%
    \pgfkeys{/tikz/text=mapped node color!80!black}%
    }
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    xmin=0,
    xmax=1,
    ymin=0,
    ymax=1,
    axis equal image,
    hide axis,
]
\addplot [scatter, only marks, mark=x,
        point meta=explicit,
        nodes near coords*,
        every node near coord/.append style={font=\footnotesize,
                                              adjust near node color}
    ] table [meta index=2] {
0.399623458645 0.202770745691 1
0.43125083774 0.374183040618 1
0.267449590519 0.086101093226 1
0.498881452071 0.0733728461989 1
0.601248587386 0.607825227731 3
0.663964417031 0.767541727794 3
0.467522971487 0.734379206102 3
0.425463065344 0.554166354467 3
0.106015995305 0.761683705293 2
0.0695936622364 0.917923977313 2
0.0957757803902 0.602873159793 2
0.2631207767 0.484806666192 2
0.919353098154 0.52159970072 0
0.769039639969 0.408860920568 0
0.58319478496 0.256712040273 0
0.6020910719 0.44509904373 0
};

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

enter image description here