You need to set
clip mode=individual. The
clip modecontrols whether markers are placed on top of everything else (
clip mode=global) or are overdrawn by following plots (
clip mode=individual). But some parts of the plot can overflow the axis boundaries which may be undesirable.
global tells pgfplots to install one single clip path for
the complete picture. In order to avoid clipped marker paths, any
markers are processed after the clip path has been closed, i.e. on a
separate layer (see
clip marker paths). An unexpected side effect is
that marks are on top of plots, even if the plots have been added
after the markers. The choice
individual instructs pgfplots to install
a separate clip path for every
\addplot command. Consequently, the
plot will be clipped. But most importantly, its markers will be drawn
immediately after the clip path has been deactivated.
clip marker paths=true
Another option is to set
clip marker paths=true instead. Then the plot will be clipped by the axis' boundaries. This option prevents an overflow of the plot over the axis' boundaries.
The initial choice
clip marker paths=false causes markers to be
drawn after the clipped region. Only their positions will be clipped.
As a consequence, markers will be drawn completely, or not at all. The
clip marker paths=true is here for backwards compatibility: it
does not introduce special marker treatment, so markers may be drawn
partially if they are close to the clipping boundary. This key has no
clip=false. Note that
clip marker paths also acts the
sequence in which plots and their markers are drawn on top of each
Finally there is also the possibility to set
clip=false. Then the entire plot won't be clipped by the axis' boundaries. This feature can be useful if you use only one x and one y axis.
% clip mode=individual, % Possibility 1
% clip marker paths=true, % Possibility 2
% clip=false, % Possibility 3
\addplot[blue, mark=x] table [x index=0,y index=1]
\addplot[green,mark=x, error bars/.cd,y explicit,y dir=both]
table [x index=0,y index=1,y error index=2]