Skip to main content
2 of 2
added 186 characters in body
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[rectangleFilling]

rectangleFilling[w_ : 12, op_ : .8, ef_ : Automatic] := 
 ReplaceAll[
  GraphicsComplex[c_, p_] :> 
   GraphicsComplex[c, 
    p /. Line[{a_, b_}, ___] :> 
      Dynamic @ {Opacity[1], Blend[{CurrentValue["Color"], White}, op], 
        EdgeForm[{AbsoluteThickness[2], 
          ef /. Automatic -> CurrentValue["Color"]}], 
        Rectangle[Offset[{-w, 0}, c[[b]]], Offset[{w, 0}, c[[a]]]]}]]

Examples:

rectangleFilling[]@
 ListPlot[{1, 2, 3, 6, 4, 4}, Filling -> Bottom, 
  FillingStyle -> Directive[CapForm["Butt"], AbsoluteThickness[5]], 
  Frame -> True, GridLines -> Automatic, 
  PlotRangePadding -> {{-0.5, 0.5}, {0.5, 0.5}}]

enter image description here

rectangleFilling[20]@
 ListPlot[MapIndexed[{{#2[[1]], #}} &]@{1, 2, 3, 6, 4, 4}, 
  PlotStyle -> "Rainbow", Filling -> 2.5, 
  FillingStyle -> Directive[CapForm["Butt"], AbsoluteThickness[5]], 
  Frame -> True, GridLines -> Automatic, 
  PlotRangePadding -> {{-0.5, 0.5}, {0.5, 0.5}}]

enter image description here

Replace Filling -> 2.5} above with Filling -> {1 -> Top, 2 -> 5, 4 -> Bottom, 6 -> 2}` to get

enter image description here

kglr
  • 400.5k
  • 18
  • 488
  • 929