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

1 次查看(过去 30 天)
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?

采纳的回答

MathWorks Support Team
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);

更多回答(0 个)

标签

尚未输入任何标签。

产品


版本

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by