8
$\begingroup$

I'm making an ErrorListPlot where the error bars are a different color then the markers and it works, however, the error bars are drawn in front of the markers and it looks funny. See the following example

Needs["ErrorBarPlots`"]

data = {{#1, #2}, ErrorBar[#3]} & @@@ RandomReal[1, {10, 3}];

ErrorListPlot[
 data,
 PlotRange -> All,
 BaseStyle -> AbsoluteThickness[2],
 PlotStyle -> RGBColor[159/255, 158/255, 204/255],
 PlotMarkers -> {{Graphics@{Opacity[1], Darker@Blue, Disk[]}, 0.01 5}}
 ]

enter image description here

See how the error bars are drawn over the markers. I want them to be behind. I tried to use Epilog to redraw the markers but they don't have a uniform aspect ratio.

Epilog -> ({Opacity[1], Darker@Blue, Disk[#, 0.025]} & /@ data[[All, 1]])

enter image description here

$\endgroup$
  • $\begingroup$ @belisarius Thanks, I forgot that. $\endgroup$ – s0rce Jul 14 '13 at 16:01
3
$\begingroup$

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, PointSize@.03, Point@data[[All, 1]]})],
              BaseStyle -> AbsoluteThickness[2]]

enter image description here

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}] &

enter image description here

less handy but more safe(?):

plot /. GraphicsComplex[x_, y_, z___] :> 
        GraphicsComplex[x, Replace[y, k_List :> Reverse@k, {3}], z]
| improve this answer | |
$\endgroup$
4
$\begingroup$

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]]]

Mathematica graphics

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks, in the end I accepted Kuba's answer since his/hers didn't require plotting twice, although the overhead of yours wasn't really relevant. $\endgroup$ – s0rce Jul 14 '13 at 20:59
  • $\begingroup$ @s0rce *his :-) $\endgroup$ – Kuba Jul 14 '13 at 22:02
2
$\begingroup$

You can also post-process ErrorListPlot output to move the Insets after the Lines:

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}]

enter image description here

Using PlotMarkers -> {Show[PolyhedronData["Dodecahedron"], Boxed -> False, ImageSize -> 30]} in elplt above, we get enter image description here

Notes: Both examples above work fine in Version 9.2. As noted by @Alexey Popkov in a comment:

  1. In version 11.2, we need to use PlotMarkers->{{Show[PolyhedronData["Dodecahedron"],Boxed->Fa‌​lse,ImageSize->30],.‌​1}}.
  2. In version 10.2+, we need to use Show[elplt, PlotRange -> All] and Show[markersInFront @ elplt, PlotRange -> All] to avoid cropping of some error bars (See also this Q/A on this issue.)
| improve this answer | |
$\endgroup$
  • $\begingroup$ (+1) For some reason PlotMarkers -> {Show[PolyhedronData["Dodecahedron"], Boxed -> False, ImageSize -> 30]} doesn't work with version 11.2.0. But the following form works: PlotMarkers->{{Show[PolyhedronData["Dodecahedron"],Boxed->False,ImageSize->30],.1}}. Also in version 11.2.0 PlotRange -> All doesn't include all the error bars, looks like a bug... $\endgroup$ – Alexey Popkov Oct 1 '17 at 6:45
  • $\begingroup$ The bug is already reported: mathematica.stackexchange.com/q/120967/280 $\endgroup$ – Alexey Popkov Oct 1 '17 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.