boxplot of matrix with different size

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

답변 (3개)

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 8월 17일

0 개 추천

You want one plot for A and one plot for B, or you want plot for every column in A and B?
Roxan
Roxan 2020년 8월 17일

0 개 추천

one plot for every column in A and B
Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 8월 17일

0 개 추천

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

Roxan
Roxan 2020년 8월 17일
thanks, in this way, I wil have first all boxes of A and then all boxes of B.
Each cloumn in A and B represents data from specifc date, so I would like to have them based on the date sorted. lets say B1, B2, A1, B3, A2,.....and so on
Thanks!
dpb
dpb 2020년 8월 17일
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))
You can change the GroupOrder property of the boxplot.
boxplot (Data,Grouping, 'GroupOrder',["B1","B2","A1", ...]);
Roxan
Roxan 2020년 8월 17일
Is there any other way?
This will become a long code, consiering that I need to plot boces from each matrix with different colors!
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', ...});

댓글을 달려면 로그인하십시오.

질문:

2020년 8월 17일

편집:

2020년 8월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by