boxplot of matrix with different size
Ältere Kommentare anzeigen
I have two matrix of diferent sizes
A=9*16
B=13* 17,
I want to plot the boxplots of both matrix in one figure.
Thanks
Antworten (3)
Abdolkarim Mohammadi
am 17 Aug. 2020
0 Stimmen
You want one plot for A and one plot for B, or you want plot for every column in A and B?
Roxan
am 17 Aug. 2020
0 Stimmen
Abdolkarim Mohammadi
am 17 Aug. 2020
A = rand (9,16);
B = rand (13,17);
[ADim1,ADim2] = size (A);
[BDim1,BDim2] = size (B);
GroupingA = strcat ("A", string(repmat(1:ADim2,[ADim1,1])));
GroupingB = strcat ("B", string(repmat(1:BDim2,[BDim1,1])));
Data = [A(:);B(:)];
Grouping = [GroupingA(:);GroupingB(:)];
boxplot (Data,Grouping);
5 Kommentare
Roxan
am 17 Aug. 2020
dpb
am 17 Aug. 2020
Sort as wanted -- the appearance of the boxes will not be modified by augmenting the shorter rows with NaN. The statistics are based on X(isfinite(X))
Abdolkarim Mohammadi
am 17 Aug. 2020
You can change the GroupOrder property of the boxplot.
boxplot (Data,Grouping, 'GroupOrder',["B1","B2","A1", ...]);
Roxan
am 17 Aug. 2020
Abdolkarim Mohammadi
am 17 Aug. 2020
Bearbeitet: Abdolkarim Mohammadi
am 17 Aug. 2020
You do not need to define properties for each group. Instead, you define all of the parameters at once in one command. For different colors for each group you can play with the ColorGroup property of the boxplot.
boxplot (Data,Grouping, ...
'GroupOrder',["B1","B2","A1", ...], ...
'ColorGroup', {'r','g','b', ...});
Kategorien
Mehr zu Box Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!