Skip to main content
10 of 12
added 685 characters in body
kglr
  • 400.5k
  • 18
  • 488
  • 929

This is clearly a bug.

In addition to the weird fence shape, the scaling behavior is also changed: fence widths change when the plot is resized.

A work-around is to post-process the output to straighten the fence lines:

ClearAll[repairFences]
repairFences = Replace[#,  Line[x_] /; Length[Dimensions@x] ==  3 :>
    (Line[Thread[{#[[;; 2, 2, 1]], #[[1, 1, 2]]}]] & /@ Partition[x, 2]), All] &;

llp = ListLogPlot[Table[{i, Around[1 + Sin[i], 0.1 + 0.1 Cos[i]]}, {i, 0, 10,  1.0}],
       PlotRange -> {All, {0.01, 10}},
       IntervalMarkers -> "Fences",
       IntervalMarkersStyle -> <|"FenceWidth" -> .3|>
       ] 

Row[Show[repairFences @ llp, ImageSize -> #]& /@ {200, 500}, Spacer[10]]

enter image description here

To get fence widths independent of image size we change the replacement rule:

ClearAll[repairFences2]
repairFences2[w_] := Replace[#,  Line[x_] /; Length[Dimensions@x] ==  3 :>
  (Line[{Offset[{-w 72 /2 , 0}, #[[1,1]]], Offset[{w 72/2 , 0}, #[[1,1]]]}]& /@ 
    Partition[x, 2]), All] &

Row[Show[repairFences2[.3] @ llp, ImageSize -> #]& /@ {200, 500}, Spacer[10]]

enter image description here

An alternative work-around is to remove IntervalMarkersStyle -> <|"FenceWidth" -> .3|> and post-process to modify the fence lines to desired length:

llp2 = ListLogPlot[Table[{i, Around[1 + Sin[i], 0.1 + 0.1 Cos[i]]}, {i, 0, 10, 1.0}],
     PlotRange -> {All, {0.01, 10}}, IntervalMarkers -> "Fences" ] 

Make fences 20 printer's points long (fence length is independent of image size):

llp2 /. Offset[{a_, _}, b_] :> Offset[{10 Sign[a] , 0}, b]

enter image description here

Make fences .3 user units long (fence length changes with image size):

llp2 /. Offset[{a_, _}, {b_, c_}] :> {b + .15 Sign[a], c}

enter image description here

You can still use IntervalMarkersStyle to style the fences:

llp3 = ListLogPlot[Table[{i, Around[1 + Sin[i], 0.1 + 0.1 Cos[i]]}, {i, 0, 10, 1.0}],
     PlotRange -> {All, {0.01, 10}}, 
     IntervalMarkers -> "Fences",
     IntervalMarkersStyle -> <|"FenceStyle" -> Red|>];

 llp3 /. Offset[{a_, _}, {b_, c_}] :> {b + .5 Sign[a], c}

enter image description here

kglr
  • 400.5k
  • 18
  • 488
  • 929