Given m_goldberg's clever trick that provides a simple and effective solution, the following is definitely an overkill ... but added flexibility may be useful.
A covenient way to inject stuff into charts is to use a custom ChartElementFunction
. The function ceF
below injects desired lines in the middle of group spacings using coordinate information (accessible to chart element functions) and BarSpacing
information passed as metadata.
We modify the input data associating with the first element of a data group a number that represents the offset from the left-bottom coordinate of the associated rectangle. Making this metadata depend on the BarSpacing
option value we center the line in the spacing between data groups. The arguments control the starting point, the length and the style of the line.
ClearAll[ceF]
ceF[start_: 2, offset_: 120, style_: Directive[Black, Thick , Dashed]] :=
Module[{}, {ChartElementDataFunction["Rectangle"][##],
style, If[#3 === {}, {}, Line[{{-start, -#3[[1]]/2 + #[[2, 1]]},
Offset[{-offset, 0}, {-start, -#3[[1]]/2 + #[[2, 1]]}]}]]}] &
Examples:
options = {ChartLabels -> {Placed[{"Rawlsian with \n corrected income taxes",
"Utilitarian (Progressive)",
" Utilitarian (Progressive) with \n corrected income taxes"}, Before], None},
ChartLayout -> "Stacked", BarOrigin -> Left, ImageSize -> Large};
With default arguments for ceF
:
BarChart[{{10, 20, 30, 10}, {30 -> .2, 20, 10, 4}, {4 -> .2, 15, 40,
20}}, options, BarSpacing -> {0, .2}, ChartElementFunction -> ceF[]]
BarChart[{{10 -> .1, 20, 30, 10}, {30 -> .6, 20, 10, 4}, {4 -> .6, 15, 40, 20}},
options, BarSpacing -> {0, .6},
ChartElementFunction -> ceF[-2, 150, Directive[Thickness[.005], DotDashed, Red]]]
Framed[Rotate[#, 360 Degree], FrameStyle -> Dotted] & /@labels
$\endgroup$360 Degree
is the same as not rotating. Shorten toFramed[#, FrameStyle -> Dotted] & /@labels
$\endgroup$