I have the following BarChart
, that uses a custom ErrorBar function to plot error bars:
errorBar[type_: "Rectangle"][{{x0_, x1_}, {y0_, y1_}}, value_,
meta_] :=
Block[{error, mags = QuantityMagnitude[value]},
error = Flatten[QuantityMagnitude[meta]];
error =
If[error === {}, 0,
Last[error]]; {ChartElementData[type][{{x0, x1}, {y0, y1}}, mags,
meta], {Black, Thick,
Line[{{{(x0 + x1)/2, y1 - error}, {(x0 + x1)/2,
y1 + error}}, {{1/4 (3 x0 + x1),
y1 + error}, {1/4 (x0 + 3 x1),
y1 + error}}, {{1/4 (3 x0 + x1),
y1 - error}, {1/4 (x0 + 3 x1), y1 - error}}}]}}]
BarChart[{{-0.08` -> 0.07`, -0.06` -> 0.07`}, {0.27` -> 0.08`,
0.12` -> 0.08`}}, ChartLegends -> {{"A", "B"}, None},
ChartLabels -> {{"Group 1", "Group 2"}, None},
ChartStyle -> {"Pastel", None},
ChartElementFunction -> errorBar["Rectangle"]]
As can be seen in the picture, the ChartLabels are plotted directly under the bars, but the error bars overlap. The ChartLabel function does not consider the length of the error bars.
I have the following question:
How can I adjust the distance between the ChartLabels and the error bars? In other words, I want the labels "Group 1", "Group 2" (and the associated lines) to be below the end of the error bars of "Group 1" and not the bars themselves (basically at the position where the y-axes ends).
AxesOrigin -> {0, -0.2}
inBarChart
$\endgroup$