Grouped boxplot with different lengths

조회 수: 9 (최근 30일)
Poulomi Ganguli
Poulomi Ganguli 2019년 7월 29일
댓글: Poulomi Ganguli 2019년 7월 29일
Hello:
I want to plot grouped boxplot in a single figure. My cell array contains foll mxn matrices.:
G1: 108x2
G2: 293x2
G3: 30x2
Each of these Gs' are different groups for which I need to plot 6 boxplot for these 3 sub-groups. Any help?

채택된 답변

Adam Danz
Adam Danz 2019년 7월 29일
편집: Adam Danz 2019년 7월 29일
You can vertically contatenate all of you data into a single column and use a [n x 2] grouping variable 'group' where group(:,1) identifies the G1, G2, G3 groups and group(:,2) identifies the column1 and column2 groups. Note that these groupings are also indicated in the x tick labels.
G1 = rand(108,2)-.5+[0,1];
G2 = rand(293,2)-.5+[2,4];
G3 = rand(30,2)-.5+[3,6];
group = [repelem([1;2;3],[numel(G1),numel(G2),numel(G3)]), ...
[repelem([1;2],size(G1,1));repelem([1;2],size(G2,1));repelem([1;2],size(G3,1))]];
boxplot([G1(:);G2(:);G3(:)],group)
  댓글 수: 3
Adam Danz
Adam Danz 2019년 7월 29일
편집: Adam Danz 2019년 7월 29일
Tip 1: x ticklabels with greek letters
boxplot(. . ., 'Labels',{'a' '\alpha' 'b' '\beta' 'g' '\gamma'})
axh = gca();
axh.XAxis.TickLabelInterpreter='tex';
Tip 2: add space between groups
boxplot(. . .,'FactorGap',[40,1])
Tip 3: add a divider line between groups
boxplot(. . .,'factorSeparator',1)
Tip 4: include greek letter in x axis label
xlabel('greek letter \alpha')
Poulomi Ganguli
Poulomi Ganguli 2019년 7월 29일
Thanks a lot!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by