Why does a BAR subplot change when I create another BAR subplot on the same figure, in MATLAB 8.0 (R2012b)?

1 view (last 30 days)
I have a simple code where I create 2 subplots with BAR graphs. When I execute this :
figure
subplot(2,1,1)
bar(round(rand(5,3)*10))
subplot(2,1,2)
bar(round(rand(5,3)*10))
The bar plots are created as expected.
However, when I execute the following code (where 'exampleBars' are my values, which span a large scales):
load exampleBars
figure
subplot(2,1,1)
bar(bar1,bar2);
subplot(2,1,2)
bar(secondX,secondY);
the first bar graph changes unexpectedly. The colour disappeared and the bars are substituted by lines.
Obviously, this is related to the data I am using. What is the problem with the data in the second example?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Oct 2013
The root cause of this issue is that BAR has lots of listeners going on for the x-axis to make it categorical. When working at large scales as in the second example, this functionality does not work very well and there are no workarounds.
A different approach for this case, is to use the AREA plot which does not have any of these issues.
load exampleBars
figure
subplot(2,1,1)
area(bar1,bar2);
subplot(2,1,2)
area(secondX,secondY);

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2012b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!