# Overlay barcharts with same vertical axis

I want to construct a bar chart for which the last bar is two bars stacked, while the others are not stacked. My thought had been to create two bar charts and overlay them. The challenge I have is that the two charts do not use the same scale for the vertical axis, as you can see below. How could I construct both charts to have the same scale?

chart1 = BarChart[
Join[Table[{0, 0}, {7}], {{1, 3}}],
ChartLabels -> {Placed[Append[Table["", {7}], "word"], Below], None},
ChartLegends -> {None, {"top", "bottom"}},
ChartLayout -> "Stacked",
]
chart2 = BarChart[
Append[Range[7], 0],
ChartLabels -> Append[Range[7], ""],
]
Overlay[{chart1, chart2}]


• Show[chart1, chart2] – Bob Hanlon Oct 18 '17 at 23:54

BarChart[Append[List /@ Range[7], {1, 3}],
ChartLayout -> "Stacked",
ChartLabels -> {Append[Range[7], "word"], None}]


• It was right under my nose. Thanks again. – FalafelPita Oct 19 '17 at 1:50
• By using grouping of 3, rather than 2, this allows me to get the coloring to differ between the first 7 bars and the last 2, which I hadn't mentioned but also wanted to do. – FalafelPita Oct 19 '17 at 2:07

It seems that a stacked bar chart will automatically determine stacking based on the size of each sub list, so the following seems to work fine for combining these:

BarChart[{{1}, {2}, {3}, {4}, {5}, {6}, {1, 3}}, ChartLayout -> "Stacked"]


If you wish to overlay two charts directly with Show, it would probably be best to make sure they have the same PlotRange, or to completely disable the axes on the smaller one (Axes -> False). Show will preserve the absolute position of the elements, but will not inform the various plotting functions of the overall plot area.

• That is helpful to know. – FalafelPita Oct 19 '17 at 1:51