Hello, I am struggling with a Boxplot using multigroup. My data is formatted as below. I like to apply a grouping variable for the columns and also for the rows. In this case, the 3 values per column belong to an observed, simulated and expected value. Within the rows, there are different settings. This is a minimal working example, but I really don't understand what the error is about, because all rows/columns match from my point of view.
But I get the error:
Error using boxplot>convertToCellarrayOfColumnVectors (line 1082)
All columns in 'G' must have the same length.
data = rand(3,10);
groupH = [0,1,0,3,1,3,0,1,1,0];
groupV = repmat([0;1;2],1,10);
boxplot(data, {groupH, group})
The Output as desired as having 3 Boxplots for same category out of h with 3 different classes from groupV directly beside. I found the following example after posting, which is quite similar, but I am really confused adapting this code for my purposes.

댓글 수: 6

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 9월 25일
Can you share the code/representational code??
jonas
jonas 2018년 9월 25일
How do you call Boxplot?
Jan Maluche
Jan Maluche 2018년 9월 26일
Sorry, I don't know why I forget to post the line. Edited the code right now.
jonas
jonas 2018년 9월 26일
Can you explain what your desired output is? How many boxes are you looking for?
Jan Maluche
Jan Maluche 2018년 9월 26일
Updated the question with the desired output. For this case I am expecting 30 boxes.
jonas
jonas 2018년 9월 26일
Okay I see the problem. Will post an answer shortly.

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

 채택된 답변

jonas
jonas 2018년 9월 26일
편집: jonas 2018년 9월 26일

0 개 추천

I found some issues with your approach. Most importantly, the number of rows in the matrix is supposed to represent the number of data points per series, which are then later visualized by a single box. Perhaps you understood this already, but each series in your example had only a single point, which was confusing to me. I have changed this to 100 pts per series of data.
This example goes on to show how to group 30 series of data in 10 different categories [1st 1st 1st 2nd 2nd 2nd ... 10th 10th 10th], with each category having three different types of series [1st 2st 3rd].
% Some data
data = rand(100,30); % 30 series, 100 pts in each
% 10 categories
% a trick to get [0 0 0 1 1 1 2 2 2 ... 9 9 9]
groupH = repmat([0:9],1,3);
groupH = reshape(groupH,10,3)'
groupH = groupH(:)
% three types of data series
groupV = repmat([0 1 2],1,10); %every third series is of the same type
% plot
boxplot(data,{groupH,groupV},'factorgap',[5 2])
.
You can see the two grouping vectors in the xlabels. Note that the grouping [0 1 2...] is redundant in this example. However, if your data is not nicely organized, then two grouping variables can be useful.

댓글 수: 2

Jan Maluche
Jan Maluche 2018년 9월 26일
Thank you, this is really helpful and totally adresses my problem.
jonas
jonas 2018년 9월 26일
Happy to help! Please mark the answer as accepted if your issue is resolved :)

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

추가 답변 (0개)

제품

릴리스

R2015b

질문:

2018년 9월 25일

댓글:

2018년 9월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by