How do I make label (node) to appear in front of markers in pgfplots?
For example in:
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates {
(1, 1)
} node[pos=0.5]{\color{green}{LABEL}};
\end{axis}
\end{tikzpicture}
\end{document}
Note that "LABEL" appears behind the plot marker:
It might be a good default (or inherited from TikZ) but how do I change this behavior? (Preferably something that still allows using the ...} node[]{...};
-syntax.)
Best Answer
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 theplot
path and therefore behind the markers.Version 1
You can shift the markers in the layer
axis tick labels
which is behind of themain
layer: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 apgfonlayer
environment on theaxis foreground
layer: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 acoordinate
in the plot path and draw the node when the plot is finished:Edit
From the manual v. 1.10, page 349:
You can define a new layer set and for example add a new layer behind
main
: