How to optimise bar chart display?
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I created a stacked bar chart from a 20 by 6 matrix. The code looks like this
sample=randi([0,10],20,6);
figure; bar(sample, 'stacked');
And this gives me the following
My problem is that there is a lot of white space from the last bar to the end of the diagram, and this makes the bars more "cramped" than they need to be. And because I need to insert xticklabels later on, it will be really helpful if the diagram can be optimised to "fit the screen". Is there any way to do that?
I ask this because normally, Matlab naturally optimises the space, such as in this 11 by 6 matrix, where there is no wasted space.
Any help is appreciated. Thank you!
0 个评论
采纳的回答
dpb
2017-5-13
编辑:dpb
2017-5-13
Hmmm....that is a failure in the internal scaling algorithm fur shure...easy enough to fix, though; bar axis center values for default are just 1:N
xlim([0 size(sample,1))+1]
to set RH limit at the last bar+1 as is LH.
The default is [0 25] so the logic internally is more concerned about rounding and even numbers even for the bar plot than it is about spacing/appearance. This is on the nuisance end, but even this is worthy of an enhancement request imo as it isn't what should have to deal with; graphics should "just work" and look good.
2 个评论
dpb
2017-5-13
Yeah, my typing is getting atrocious--and the '1' was certainly intended as 0. I'll fixup answer...
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!