You need to add the only marks
option to the \addplot
:

Code:
\documentclass{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[domain=0:3]
\begin{axis}[xlabel={$T_{\text{meas}}$}, ylabel={$T_{\text{cal}}$}]
\addplot[scatter, only marks, scatter src=\thisrow{class},
error bars/.cd, y dir=both, x dir=both, y explicit, x explicit, error bar style={color=mapped color}]
table[x=x,y=y,x error=xerr,y error=yerr] {
x xerr y yerr class
0.98521 0.00031 1 0.000001 0
0.49238 0.00044 0.5 0.00000025 0
1.09346 0.00032 1.111111 0.0000012 0
1.23021 0.00078 1.25 0.0000016 0
1.40567 0.00047 1.428571 0.000002 0
1.63971 0.00064 1.666667 0.0000028 0
1.96753 0.00063 2 0.000004 0
};
\end{axis}
\end{tikzpicture}
\end{document}
Normally markers are drawn on top of all plots in an axis
environment (clip mode=global
, default) or at least on top of the single plot (clip mode=individual
) to avoid clipping the markers. In your code the node is part of the plot
path and therefore behind the markers.
Version 1
You can shift the markers in the layer axis tick labels
which is behind of the main
layer:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{
set layers,% using layers
mark layer=axis tick labels% defines the layer of the marks
}
\begin{axis}
\addplot coordinates {
(0.5,0.5) (1, 1) (1.5,1.5)
} node[pos=0.5]{\color{green}{LABEL}};
\end{axis}
\end{tikzpicture}
\end{document}

Note that then all markers will be behind all plots in the same axis environment.
Version 2
Set a coordinate
in the plot path and draw the node in a pgfonlayer
environment on the axis foreground
layer:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{set layers}% using layers
\begin{axis}[set layers]
\addplot coordinates {
(0.5,0.5) (1, 1) (1.5,1.5)
} coordinate[pos=0.5](p1);% coordinate in the middle of the plot path
\begin{pgfonlayer}{axis foreground}
\node at (p1){\color{green}{LABEL}};% draw the node in the axis foreground
\end{pgfonlayer}
\end{axis}
\end{tikzpicture}
\end{document}
Unfortunately I don't know how to change the layer for the node directly in their options. But maybe there is such a possibility.
Version 3
Use clip mode=invidual
, set a coordinate
in the plot path and draw the node when the plot is finished:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[clip mode=individual]
\addplot coordinates {
(0.5,0.5) (1, 1) (1.5,1.5)
} coordinate[pos=0.5](p1);% coordinate in the middle of the plot path
\node at (p1){\color{green}{LABEL}};
\end{axis}
\end{tikzpicture}
\end{document}
Edit
From the manual v. 1.10, page 349:
The layers/standard
layer configuration is defined by
\pgfplotsset{
layers/standard/.define layer set=
{axis background,axis grid,axis ticks,axis lines,axis tick labels,main,%
axis descriptions,axis foreground}
{
grid style= {/pgfplots/on layer=axis grid},
tick style= {/pgfplots/on layer=axis ticks},
axis line style= {/pgfplots/on layer=axis lines},
label style= {/pgfplots/on layer=axis descriptions},
legend style= {/pgfplots/on layer=axis descriptions},
title style= {/pgfplots/on layer=axis descriptions},
colorbar style= {/pgfplots/on layer=axis descriptions},
ticklabel style= {/pgfplots/on layer=axis tick labels},
axis background@ style={/pgfplots/on layer=axis background},
3d box foreground style={/pgfplots/on layer=axis foreground},
},
}
You can define a new layer set and for example add a new layer behind main
:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{
layers/mylayers/.define layer set=
{axis background,axis grid,axis ticks,axis lines,axis tick labels,%
axis mymarks,% additional layer behind main
main,axis descriptions,axis foreground}
{/pgfplots/layers/standard}% re-uses the style definitions of layers/standard
}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{
set layers=mylayers,% using mylayers
mark layer=axis mymarks% defines the layer of the marks
}
\begin{axis}
\addplot coordinates {
(0.5,0.5) (1, 1) (1.5,1.5)
} node[pos=0.5]{\color{green}{LABEL}};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
This should get you started:
The code itself is self explanatory IMO. For details, run
texdoc pgfplots
from command prompt/terminal and look in to thepgfplots
manual.