# Multiple histograms grouped in a chart

I have this problem: I have three distributions and the relative histograms. But I would like to create an histogram in which the three columns of each single histogram for the same bin are put together (grouped) by the same x axis value. There is someone could help me?

-
I tried also with BarChart but I wasn't able to put the three columns for each bin side by side. –  Roryro87 Jun 28 at 11:47
Can you explain why the obvious Histogram[{data1,data2,...}] is not good? –  Szabolcs Jun 28 at 13:56
It is not my choice unfortunately,but I needed to get the histograms more easily readable. –  Roryro87 Jun 28 at 14:48
It was not clear from your explanation that you wanted to have the bars next to each other instead of on top of each other. I did not understand the question until you commented on one of the answers. –  Szabolcs Jun 28 at 14:50
Sorry It wasn't easy to exaplain the problem but next time I will try to be more clear. –  Roryro87 Jun 28 at 14:54

Unlike BarChart (with its default ChartLayout option setting Grouped) Histogram does not accept Grouped as a ChartLayout option value. So, we need to transform the data to get the bin heights and use transformed data in BarChart:

d1 = RandomVariate[NormalDistribution[0, 1/2], 50];
d2 = RandomVariate[NormalDistribution[0, 1], 50];
d3 = RandomVariate[NormalDistribution[1, 1/2], 50];

BarChart[Transpose[(HistogramList[#, {-3, 4, 1}, "Count"] & /@ {d1, d2, d3})[[All, 2]]],
ChartStyle -> "Rainbow", ChartLabels -> {Range[-3, 4, 1], None},
ChartLegends -> {"d1", "d2", "d3"}]


Update: Alternative layouts with the three histograms side-by-side:

BarChart[(HistogramList[#, {-3, 4, 1}, "Count"] & /@ {d1, d2, d3})[[All, 2]],
ChartStyle -> {"Rainbow", None},
ChartLabels -> {{"d1", "d2", "d3"}, Range[-3, 4, 1]},
ChartLegends -> {{"d1", "d2", "d3"}, None},
BarSpacing -> {None, Automatic}]


 BarChart[(HistogramList[#, {-3, 4, 1}, "Count"] & /@ {d1, d2,  d3})[[All, 2]],
ChartStyle -> "Rainbow",
ChartLabels -> {{"d1", "d2", "d3"}, Range[-3, 4, 1]},
ChartLegends -> Range[-3, 4, 1],
BarSpacing -> {None, Automatic}]


-
+1 (except that I get a different result at +2 and -3) –  eldo Jun 28 at 13:07
This is just what I mean, the only thing I did't need the Transpose command. Thank you :) –  Roryro87 Jun 28 at 14:46

You might also be interested in SmoothHistogram (new in v8).

d1 = RandomVariate[NormalDistribution[0, 1], 500];
d2 = RandomVariate[NormalDistribution[3, 1], 500];
d3 = RandomVariate[NormalDistribution[5, 1], 500];

SmoothHistogram[{d1, d2, d3},
Axes -> False, Frame -> True,
PlotLegends -> {"d1", "d2", "d3"},
Filling -> Axis]


-