Bar graphs don't group bars if there is only one group in the data
조회 수: 13(최근 30일)
표시 이전 댓글
I have a lot of bar graphs to plot. The bars must be grouped into pairs. If the number of pairs is one, then grouping doesn't seem to work:
% Artificial data: Two vertical vectors of height 3
x=reshape(randperm(6),3,2)
% Correct grouping into pairs
subplot(1,2,1)
barh(x);
% NO grouping :(
subplot(1,2,2)
barh(x(1,:));

Is there any way to force barh to group consistently? I want each column of "x" to form a series, even if it is a series of 1. So x(1,:) forms two series, only 1 bar each. In the grouped bar chart, it should form one group of two bars, each bar with a different colour (just like each group on the left subplot). In contrast, the right subplot shows that it forms a single series of two bars (or a single series of two groups, each containing one bar). They also have separate tick lables, which bars in the same group should not.
I am using Matlab 2022a.
댓글 수: 1
채택된 답변
추가 답변(0개)
참고 항목
범주
Find more on Graphics Object Properties 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!