# Creating a stacked RectangleChart

I would like to make a "Stacked" BarChart where the bars have variable widths, like a RectangleChart. However, RectangleChart does not accept ChartLayout -> "Stacked".

Is there a way to do this, or does anyone have a workaround?

For example, here is a RectangleChart with the bars at different widths:

Here is a "Stacked" BarChart with the bars decomposed into two components:

I would like to make a stacked RectangleChart with variable-width bars that can be decomposed into components.

-

Actually, RectangleChart does accept ChartLayout -> "Stacked". Consider for example

data = Table[{i^2, RandomReal[]}, {i, 5}, {j, 5}];

RectangleChart[data, ChartLayout -> "Stacked"]


-
Great, that seems to work! Strange that the docs don't mention it (reference.wolfram.com/mathematica/ref/RectangleChart.html says 'Possible settings for ChartLayout include "Grouped" and "Stepped"'). –  tba May 2 '12 at 20:08
You gotta be careful with the wording: "include" does not mean "are only the following". Not that I'm saying its a helpful statement, just that the docs don't mention all the options available...almost as bad as "up to 50% off"... –  tkott May 2 '12 at 20:35
Yes, it works, but you have to be careful. RectangleChart[RandomReal[1, {5, 5, 2}], ChartLayout -> "Stacked"] is interesting, but it's not obvious to me how useful it is. –  Brett Champion May 2 '12 at 21:04
@BrettChampion It might be useful if you need to draw several non-stacked barcharts in the same figure: data = Table[{RandomReal[{0, 2}], 1}, {3}, {4}]; RectangleChart[data, ChartLayout -> "Stacked", BarOrigin -> Left] –  VLC May 3 '12 at 8:09
@VLC Interesting idea, although the axes are 'wrong' in that case. –  Brett Champion May 3 '12 at 14:06