How does the Boxplot 'grouporder' parameter work?
21 ビュー (過去 30 日間)
古いコメントを表示
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163145/image.png)
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'
0 件のコメント
回答 (1 件)
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).
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Probability Distributions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!