Why does a BAR subplot change when I create another BAR subplot on the same figure, in MATLAB 8.0 (R2012b)?
1 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2013-10-25
回答: MathWorks Support Team
2013-10-25
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
2013-10-25
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!