1

This is a follow-up to some related questions: 46770 and 60600.


I'd like to make a DistributionChart where the elements are histograms with my own custom settings. For example, I'd like to be able to take:

data = WeightedData[Range[10], #] & /@ RandomInteger[20, {5, 10}];

and make a DistributionChart where each element looks like, say,

Histogram[data[[i]],10,{"Log","Probability"}][[1]]

for the appropriate value of the iterator, i (ideally with the histogram bars centered rather than edge-aligned). I tried something similar to this answer:

Module[
  {cef :=
    Histogram[#2,10,{"Log", "Probability"}, BarOrigin -> Left][[1]] /. 
      RectangleBox[{x0_, y0_}, {x1_, y1_}, z___] :> 
        RectangleBox[
          {(- x1  + #[[1, 1]] + #[[1,2]])/2, y0},
          {(x1 + #[[1, 1]] + #[[1, 2]])/2, y1}, z] &},
  DistributionChart[data, ChartElementFunction -> cef]]

The code above almost works, but because the bars of the histograms can have length greater than 1, they can overlap. (It works fine if {"Log", "Probability"} is changed to "Probability".) I can fix this on a case-by-case basis by scaling down the bar lengths by some factor, but is there a way to do it automatically?

Daniel Weissman
  • 235
  • 2
  • 6

0 Answers0