Let’s create some sample data
Clear["Global`*"]; n = 10000; data0 = Table[{RandomReal[{-1, 1}], RandomReal[{-1, 1}], RandomInteger[{0, 50}], RandomInteger[{-2, 5}]}, {i, 1, n}];
and make a selection
data = Select[data0, (#[[4]] > 0) &];
Now let’s create the histogram
datan = Table[Abs[data[[i, 3]]], {i, 1, Length[data]}]; P0 = Histogram[datan, Automatic, "Probability", ChartStyle -> Gray, ChartBaseStyle -> EdgeForm[None], Frame -> True, FrameLabel -> {"t", "P"}, RotateLabel -> False, LabelStyle -> Directive[FontFamily -> "Helvetica", 20], Epilog -> {Red, Thick, Dashed, Line[{{#, 0}, {#, 1}} &@Last@Commonest[datan]]}, PlotRange -> All, PlotRangePadding -> 0.001, AspectRatio -> 1, ImageSize -> 550]
The histogram corresponds to those data for which the fourth column is an integer 1, 2, 3, 4, or 5. Now I want the following: Split each column of the histogram in five bits (with different color), thus showing the contribution of each of the five possibilities (1, 2, 3, 4, 5).
Any suggestions?