Boxplot does not work

26 views (last 30 days)
Abinet
Abinet on 8 Nov 2014
Commented: the cyclist on 8 Nov 2014
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 Comment
Geoff Hayes
Geoff Hayes on 8 Nov 2014
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.)

Sign in to comment.

Answers (2)

the cyclist
the cyclist on 8 Nov 2014
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 Comment
Abinet
Abinet on 8 Nov 2014
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?

Sign in to comment.


the cyclist
the cyclist on 8 Nov 2014
Edited: the cyclist on 8 Nov 2014

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 Comments
Abinet
Abinet on 8 Nov 2014
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 on 8 Nov 2014
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.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!