Boxplot does not work

조회 수: 3 (최근 30일)
Abinet
Abinet 2014년 11월 8일
댓글: the cyclist 2014년 11월 8일
Hello All, I wanted to use boxplot in matlab. But I got those errors.
Error using boxplot>assignUserLabels (line 1660)
Points with more than one value of the 'labels' parameter are in the same group.
Error in boxplot>identifyGroups (line 1225)
[userLabelsByGroup,numUserLabelVars,skipLabelGrouporderScramble] = ...
Error in boxplot (line 286)
[groupIndexByPoint,groupVisibleByPoint,labelIndexByGroup,gLevelsByGroup,...
Error in Boxplottrial (line 14)
boxplot(values, 'Label', {'A', 'B', 'C','D','F','G','H','I','J','K'})
Here is the matlab code I used.... Any help please,
cm1S1=19.2093;
cm1=16.9359;
cm2=14.3030;
cm3=14.6428;
cm4=16.2188;
cm5=16.6686;
cm6=17.2386;
cm7=17.1935;
cm8=16.9363;
cm9=16.3418;
values=[cm1S1;cm1;cm2;cm3;cm4;cm5;cm6;cm7;cm8;cm9];
figure
boxplot(values, 'Label', {'A', 'B', 'C','D','F','G','H','I','J','K'})
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2014년 11월 8일
Abinet - what are you attempting to show with the labels? Since your values is a column vector, I think only one box plot should appear on the figure (see boxplot, if X is a vector, there is just one box.)

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

답변 (2개)

the cyclist
the cyclist 2014년 11월 8일
This code will work, because you are plotting just one distribution, and there is one label:
cm1S1=19.2093;
cm1=16.9359;
cm2=14.3030;
cm3=14.6428;
cm4=16.2188;
cm5=16.6686;
cm6=17.2386;
cm7=17.1935;
cm8=16.9363;
cm9=16.3418;
values=[cm1S1;cm1;cm2;cm3;cm4;cm5;cm6;cm7;cm8;cm9];
figure
boxplot(values, 'Label', {'A'})
  댓글 수: 1
Abinet
Abinet 2014년 11월 8일
Hi, Thanks for the comment. But my aim is to display all the values on individually boxplot together. One for each of them. I dont want to plot just one of the value. Is it possible?

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


the cyclist
the cyclist 2014년 11월 8일
편집: the cyclist 2014년 11월 8일

This is a different guess at what you mean.

cm1S1=19.2093;
cm1=16.9359;
cm2=14.3030;
cm3=14.6428;
cm4=16.2188;
cm5=16.6686;
cm6=17.2386;
cm7=17.1935;
cm8=16.9363;
cm9=16.3418;
values=[cm1S1;cm1;cm2;cm3;cm4;cm5;cm6;cm7;cm8;cm9];
numberValues = numel(values);
label = {'A', 'B', 'C','D','F','G','H','I','J','K'};
figure
hold on
boxplot(values)
plot(1,values,'r*')
for nv = 1:numberValues
    text(1.1,values(nv),label(nv))
end
  댓글 수: 2
Abinet
Abinet 2014년 11월 8일
Thank you so much again, Now, I could understand that how boxplot display for individual points. But as I told you my aim is to plot many elements on individual plot as shown in the example. but I am not sure that boxplot support that because the example does not work.
x1=rand(4,5); x2=rand(6,3); x3=rand(8,5); figure boxplot(x1,'label','A'); hold on; boxplot(x2,'label','B'); hold on; boxplot(x3,'label','C');
the cyclist
the cyclist 2014년 11월 8일
In your original question, you showed just one vector of data. Now you have three different matrices, each of a different size. That is very different. It is not at all clear what sets of data belong in the same distribution with each other, and what you are trying to label.

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by