Place PlotMarkers in front of error bars with ErrorListPlot
The most obvious ...
data = {{#1, #2}, ErrorBar[#3]} & @@@ RandomReal[1, {10, 3}];
Needs["ErrorBarPlots`"]
Show[ErrorListPlot[data, PlotRange -> All,
BaseStyle -> AbsoluteThickness[2],
PlotStyle -> RGBColor[159/255, 158/255, 204/255],
PlotMarkers -> None],
ListPlot[data[[All, 1]],
PlotStyle -> Directive[PointSize[Medium], Red]]]
1
A little improvement of Your approach would be using Point
instead of Disk
:
ErrorListPlot[data, PlotRange -> All, PlotStyle -> Orange, PlotMarkers -> None,
Epilog -> ({Darker@Blue, [email protected], Point@data[[All, 1]]})],
BaseStyle -> AbsoluteThickness[2]]
2
Not so obvious and I'm not sure if universal for ErrorListPlot
but:
plot = ErrorListPlot[data, PlotRange -> All, BaseStyle -> AbsoluteThickness[2],
PlotMarkers -> {{Graphics@{Opacity[1], Darker@Blue, Disk[]}, 0.01 5}},
PlotStyle -> Orange];
plot// Replace[#, k_List :> Reverse@k, {6}] &
less handy but more safe(?):
plot /. GraphicsComplex[x_, y_, z___] :>
GraphicsComplex[x, Replace[y, k_List :> Reverse@k, {3}], z]
You can also post-process ErrorListPlot
output to move the Inset
s after the Line
s:
ClearAll[markersInFront]
markersInFront = # /. {i_Inset, x__} :> {x, i} &;
Examples:
elplt = ErrorListPlot[data, PlotRange -> All,
BaseStyle -> AbsoluteThickness[2], ImageSize -> 400,
PlotStyle -> RGBColor[159/255, 158/255, 204/255],
PlotMarkers -> {{Graphics@{Opacity[1], Darker@Blue, Disk[]}, 0.01 5}}];
Row[{elplt, markersInFront @ elplt}]
Using PlotMarkers -> {Show[PolyhedronData["Dodecahedron"], Boxed -> False, ImageSize -> 30]}
in elplt
above, we get
Notes: Both examples above work fine in Version 9.2. As noted by @Alexey Popkov in a comment:
- In version 11.2, we need to use
PlotMarkers->{{Show[PolyhedronData["Dodecahedron"],Boxed->False,ImageSize->30],.1}}
. - In version 10.2+, we need to use
Show[elplt, PlotRange -> All]
andShow[markersInFront @ elplt, PlotRange -> All]
to avoid cropping of some error bars (See also this Q/A on this issue.)