This is a rewording of a previous question which probably wasn't very well explained, and so didn't get any responses(!). I'm trying to create a chart which shows the smooth kernel distribution of three datasets, a box and whisker chart (below) and the histogram of the datasets laid under the kernel distribution. However, because the data is quite close to each other, I've arrange the 'histogram' into a bar chart so that the data can be displayed side by side (rather than stacked or overlapping, which is confusing with this data).
I've managed to get all three charts to show up (with some much appreciated help from others on this site), but the bar chart (histogram) is completely the wrong scale. (See image below)
When I break them down and display the charts separately though, the scaling is fine:
Here is the code:
S086 = {33.00, 55.74, 46.68, 22.26, 45.05, 41.95, 82.26, 58.79, 30.89,30.89,47.21, 30.16, 17.16, 28.05, 25.63}
T086 = {34.65, 28.52, 9.77, 38.58, 32.03, 22.26, 35.16, 45.26, 21.71,29.26, 34.71, 22.16}
X086 = {23.41, 48.54, 32.97, 28.57, 23.35, 20.70, 35.49, 21.97, 29.81,17.65, 16.73, 15.32, 16.00}
datasets = {{S086}, {T086}, {X086}}
bin = HistogramList[Flatten[datasets]][[1]]
and then (I've removed the box chart to simplify the code)
Show[
Plot[140 PDF[SmoothKernelDistribution[#], x] & /@ {S086, T086,
X086}, {x, 0, 100}, Evaluated -> True,
PlotStyle -> {{Thickness[0.01],
RGBColor[0.23, 0.42, 0.63]}, {Thickness[0.01],
RGBColor[0.29, 0.53, 0.80]}, {Thickness[0.01],
RGBColor[0.62, 0.73, 0.88]}}, Frame -> True,
GridLines -> Automatic],
BarChart[Transpose@(BinCounts[#, {bin}] & /@ {S086, T086, X086}),
Axes -> False,
ChartStyle -> {Opacity[0.75, RGBColor[0.23, 0.42, 0.63]],
Opacity[0.75, RGBColor[0.29, 0.53, 0.80]],
Opacity[0.75, RGBColor[0.62, 0.73, 0.88]]},
PlotRange -> Automatic, PlotRangePadding -> None]]
BarChart
uses a x-value of 1 for each bar (or bar position). So for your 9 groups of 3 bars your bar plot only extends up to around x=27, which is what you see when you useShow
with thePlot
which goes up to 100. $\endgroup$