Is it possible to set the size of the gap between grouped bars in a bar graph?
120 views (last 30 days)
Show older comments
I know you can set the width of each bar (I set mine near max) but I am curious if I can minimize the white space by decreasing the x distance between each pair (group) of bars.
This is what I am plotting:
coh = [0.9862, 0.9773
0.971, 0.9544
0.8969, 0.6791
0.8835, 0.9051
0.8558, 0.6727
0.6727, 0.8641];
figure
hB=bar(coh,.95);
Thank you!
0 Comments
Accepted Answer
the cyclist
on 30 Jun 2020
Edited: the cyclist
on 30 Jun 2020
Another option would be to abandon using grouped bars in a single call to bar(), and instead plot the two sets of bars with two different calls to bar(), and specifying the x locations of those bars.
figure
hold on
w = 0.4;
bar((1:6)-w/2,coh(:,1),w)
bar((1:6)+w/2,coh(:,2),w)
More Answers (1)
the cyclist
on 30 Jun 2020
This question and the answer from MATLAB staff suggest that it is not possible using the built-in bar function.
However, there is another answer from someone who contributed the barmod function to the File Exchange, claiming to solve this problem. It's quite new, and I have not tried it, but it might be worth a shot.
See Also
Categories
Find more on Discrete Data Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!