1
$\begingroup$

Data:

  • three categories A,B,C
  • values in each category: {median-semiIQR, sIQR (such that this value = median), sIQR (such that this value = median + sIQR)}

e.g. {{90, 21, 21}, {57, 14, 14}, {117, 69, 69}}

What I want:

Preferably, just bar indicating the median value, then an errorbar added, indicating the sIQR, but how is this done in a PBC?

Else: cat. A is Red, cat. B Blue and cat. C Green. The last two values of each category have to be Blended, so that they are Pinkish, Lightblueish and LightGreenish, to indicate that these are sIQRs.

In addition, I would like to display the median value for each category

$\endgroup$
2
  • $\begingroup$ ErrorBar or ErrorListPlot? Needs["ErrorBarPlots`"]. $\endgroup$
    – Apple
    Sep 10, 2014 at 9:47
  • $\begingroup$ reference.wolfram.com/language/howto/Files/…. I'd like to have somthing like this, but the method mentioned there doesn't work with a PBC (that has its bars in the horizontal direction) $\endgroup$
    – user18798
    Sep 10, 2014 at 9:49

1 Answer 1

2
$\begingroup$

A partial answer addressing the PBC part of the question...

Using a modification of the function errorBar in OP's other question (Spacing the elements in a bar chart with error bars) to make it work with PairedBarChart:

ClearAll[pbcErrorBar];
pbcErrorBar[type_: "GlassRectangle"][{{x0_, x1_}, {y0_, y1_}}, value_, meta_] :=
 Block[{error, z}, error = Flatten[meta];
  error = If[error === {}, 0, Last[error]]; z = If[x0 < 0, x0, x1];
  {ChartElementData[type][{{x0, x1}, {y0, y1}}, value, meta],
   {Black, Line[{{{z - error, (y0 + y1)/2}, {z + error, (y0 + y1)/2}},
      {{z + error, 1/4 (3 y0 + y1)}, {z + error, 1/4 (y0 + 3 y1)}},
      {{z - error, 1/4 (3 y0 + y1)}, {z - error, 1/4 (y0 + 3 y1)}}}]}}];

and data similar to the one in the same Q/A:

cd = {RandomReal[1, 10], RandomReal[0.1, 10]};
chartData = Flatten@MapThread[{#1 -> #2} &, cd];
chartData2 = MapAt[# + RandomReal[] &, chartData, {{;; , 1}}];

we get

PairedBarChart[{chartData}, {chartData2},
 ChartElementFunction -> pbcErrorBar[],
 ChartStyle -> Rest@ColorData[3, "ColorList"], ImageSize -> 500,
 BaseStyle -> {FontFamily -> "Segoe UI", FontSize -> 16},
 ChartLabels -> {Placed[Style[#, "Panel", 16] & /@ {"A", "B"}, Above],
                       None, Style[#, "Panel", 14] & /@ CharacterRange["a", "j"]}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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