필터 지우기
필터 지우기

How does the Boxplot 'grouporder' parameter work?

조회 수: 21 (최근 30일)
Eric
Eric 2014년 5월 21일
답변: liomsi liomsi 2019년 1월 24일
I am making a boxplot with grouping based on two categorical string/cell variables.
How do I use the 'grouporder' parameter to reorder the second level grouping (m.case) so that vertical order is Case 1, Case 2, Case 1, Case 2.... instead of Case 2, Case 1, Case 2, Case 1, ... ?
Ideally, I'd like to control the first level group order ( 'AV/AVW CHL1', 'GSM CHL1', 'MERIS CHL2') too instead of using 'ydir'.
Here's the existing code:
h = boxplot(m.bias, {m.types, m.case}, 'plotstyle', 'traditional', ... 'labelorientation', 'inline','notch', 'on', 'orientation', 'horizontal',... 'colorgroup', {m.case}, 'colors', [1 0 0 ; 0 .7 0]); set(gca, 'ydir', 'reverse'); ylm = ylim; hold on; plot([0 0], ylm, 'k:');
>> unique(m.types)
ans =
'AV/AVW CHL1'
'GSM CHL1'
'MERIS CHL2'
>> unique(m.case)
ans =
'Case 1'
'Case 2'

답변 (1개)

liomsi liomsi
liomsi liomsi 2019년 1월 24일
You can convert your m.case to categories, then it should keep the order you gave during the definition of the categories, and you don't need the 'grouporder' option.
m.case = categorical(m.case,{'Case 1','Case 2'}, 'Ordinal',true).

카테고리

Help CenterFile Exchange에서 Probability Distributions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by