How to use multiple grouping variables in boxplot? Why box plot grouping variable 'not same length' error?
Ältere Kommentare anzeigen
1. How do I use multiple grouping variables?
2. How do I resolve the borrowing incorrect error?
Error message:
>> BoxplotGICategoriesDVH
Error using boxplot>straightenX (line 969)
G must be the same length as X or the same length as the
number of columns in X.
Error in boxplot (line 273)
[xDat,gDat,origRow,xlen,gexplicit,origInd,origNumXCols]
= straightenX(x,g);
Error in BoxplotGICategoriesDVH (line 8)
boxplot(data,group)
Verifying that G is "the same length as the number of columns in X":
>> length(group)
ans =
3
>> data
data =
4 18 30
5 8 9
Code causing the error:
data = round(10*rand(2,3));
data(:,2)=2*data(:,2);
data(:,3)=3*data(:,3);
group = cell(3,1);
group{1} = {'1','a'};
group{2} = {'2','b'};
group{3} = {'3','c'};
boxplot(data,group)
How do I resolve this error?
1 Kommentar
Daniel Bridges
am 27 Feb. 2018
Bearbeitet: Daniel Bridges
am 27 Feb. 2018
Akzeptierte Antwort
Weitere Antworten (1)
Jan
am 27 Feb. 2018
I'm not sure what you are exactly asking for. But maybe this helps:
data = round(10*rand(2,3));
data(:,2) = 2*data(:,2);
data(:,3) = 3*data(:,3);
group = {'a', 'b', 'c'}
boxplot(data, group)
2 Kommentare
Daniel Bridges
am 28 Feb. 2018
Bearbeitet: Daniel Bridges
am 28 Feb. 2018
Issa
am 28 Aug. 2019
how to set different Whisker for each group in matlab boxplot
Kategorien
Mehr zu Descriptive Statistics and Visualization finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!