How to optimise bar chart display?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
dpb
am 13 Mai 2017
Bearbeitet: dpb
am 13 Mai 2017
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 Kommentare
dpb
am 13 Mai 2017
Yeah, my typing is getting atrocious--and the '1' was certainly intended as 0. I'll fixup answer...
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!