Azzera filtri
Azzera filtri

How does the Boxplot 'grouporder' parameter work?

21 visualizzazioni (ultimi 30 giorni)
Eric
Eric il 21 Mag 2014
Risposto: liomsi liomsi il 24 Gen 2019
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'

Risposte (1)

liomsi liomsi
liomsi liomsi il 24 Gen 2019
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).

Community Treasure Hunt

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

Start Hunting!

Translated by