Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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:

enter image description here

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

enter image description here

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

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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

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

RectangleChart[data, ChartLayout -> "Stacked"]

Mathematica graphics

share|improve this answer
1  
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
1  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.