plotting – How to set specific bin and width for each dataset within a Histogram3D


nd = 40;
SeedRandom(1)
dts = RandomVariate(NormalDistribution(40 + #, 10), 1000) & /@ Range(nd);

idts = MapIndexed(Thread({#, 50 (#2((1)))}) &, dts);

First 5 rows of the first data set:

idts((1, ;; 5)) // Grid(#, Dividers -> All) &

enter image description here

Histogram3D(idts, {{"Raw", 66}, {"Raw", nd}}, "Count", 
 ImageSize -> 700, 
 ChartLegends -> {"data" <> ToString(50 #) & /@ Range(nd)}, 
 Ticks -> {Range(0, 100, 5), Range(0, 2000, 100), Automatic})

enter image description here

To see the first 10 data sets in more detail:

Histogram3D(idts((;; 10)), {{"Raw", 66}, {"Raw", 10}}, "Count", 
 ImageSize -> 800, 
 ChartLegends -> {"data" <> ToString(50 #) & /@ Range(10)}, 
 Ticks -> {Range(0, 100, 5), Range(0, 2000, 50), Automatic})

enter image description here

To chart non-contiguous subsets of the 40 data sets, we need to change the bin specification for the y direction to {50} ( or to {50,2000,50}):

Histogram3D(idts(({1, 5, 12, 20, 24})), {{"Raw", 66}, {50}}, "Count", 
 ImageSize -> 800, 
 ChartLegends -> {"data" <> ToString(50 #) & /@ {1, 5, 12, 20, 24}}, 
 Ticks -> {Range(0, 100, 5), Range(0, 2000, 50), Automatic})

enter image description here

To show only two of 40 datasets we need a trick (to work around a possible bug): add a third data set and set its style to None:

Histogram3D(idts(({1, 40, 40})), {{"Raw", 66}, {50}}, "Count", 
 ImageSize -> 700, 
 ChartStyle -> {{ ColorData(97) @ 1, ColorData(97) @ 40, None}}, 
 ChartLegends -> ("data" <> ToString(50 #) & /@ {1, 40}), 
 Ticks -> {Range(0, 100, 5), Range(0, 2000, 100), Automatic})

enter image description here

The specification {"Raw", 66} gives 66 bins in x direction for the combined data set:

Length(HistogramList(Join @@ idts, {{"Raw", 66}, {"Raw", nd}}, "Count")((1, 1))) - 1
66

To get 66 bins for each data set, we can chart each set separately and combine the charts with Show:

Show(MapIndexed(Histogram3D(#, {{"Raw", 66}, {#((1, 2)), #((1, 2)) + 50, 50}}, 
    "Count", ChartBaseStyle -> Opacity(.5), 
    ChartStyle -> ColorData(97)(#2((1))), 
    ChartLegends -> {"data" <> ToString(50 #2((1)))}) &, idts((;; 10))), 
 PlotRange -> All, ImageSize -> 700, 
 Ticks -> {Range(0, 100, 5), Range(0, 2000, 50), Automatic})

enter image description here