# Thread Subject: boxplot, grouping variables

 Subject: boxplot, grouping variables From: Valentina Date: 19 Jun, 2009 09:40:18 Message: 1 of 8 Hi, I would like to create a box plot of my samples, but these samples have different sizes. I can combine all the samples in just one vector and then use grouping variables, but I don't understand how they work. so for example, if I have 3 samples t1,t2 and t3 of lengths 43,148,228 respectively, how would the function boxplot be filled in? Something like boxplot(cat(1,t1,t2,t3),....)? Thank you very much! Valentina
 Subject: boxplot, grouping variables From: Anon Date: 19 Jun, 2009 10:53:01 Message: 2 of 8 Hi Valentina, try following: group = [ones(size(t1);ones(size(t2))+1;ones(size(t3))+2]; x = cat(1,t1,t2,t3); boxplot(x,group); HTH "Valentina " wrote in message ... > Hi, > I would like to create a box plot of my samples, but these samples have different sizes. I can combine all the samples in just one vector and then use grouping variables, but I don't understand how they work. so for example, if I have 3 samples t1,t2 and t3 of lengths 43,148,228 respectively, how would the function boxplot be filled in? Something like boxplot(cat(1,t1,t2,t3),....)? > > Thank you very much! > > Valentina
 Subject: boxplot, grouping variables From: Valentina Date: 19 Jun, 2009 11:17:02 Message: 3 of 8 Thank you very much, it worked perfectly! Valentina "Anon " wrote in message ... > Hi Valentina, > > try following: > group = [ones(size(t1);ones(size(t2))+1;ones(size(t3))+2]; > x = cat(1,t1,t2,t3); > boxplot(x,group); > > HTH > > > > "Valentina " wrote in message ... > > Hi, > > I would like to create a box plot of my samples, but these samples have different sizes. I can combine all the samples in just one vector and then use grouping variables, but I don't understand how they work. so for example, if I have 3 samples t1,t2 and t3 of lengths 43,148,228 respectively, how would the function boxplot be filled in? Something like boxplot(cat(1,t1,t2,t3),....)? > > > > Thank you very much! > > > > Valentina
 Subject: boxplot, grouping variables From: Nuno Almeida Date: 3 Jun, 2011 11:28:04 Message: 4 of 8 "Anon" wrote in message ... > Hi Valentina, > > try following: > group = [ones(size(t1);ones(size(t2))+1;ones(size(t3))+2]; > x = cat(1,t1,t2,t3); > boxplot(x,group); > > HTH > > > > "Valentina " wrote in message ... > > Hi, > > I would like to create a box plot of my samples, but these samples have different sizes. I can combine all the samples in just one vector and then use grouping variables, but I don't understand how they work. so for example, if I have 3 samples t1,t2 and t3 of lengths 43,148,228 respectively, how would the function boxplot be filled in? Something like boxplot(cat(1,t1,t2,t3),....)? > > > > Thank you very much! > > > > Valentina
 Subject: boxplot, grouping variables From: Aldo Amaya Date: 16 Aug, 2011 22:59:12 Message: 5 of 8 Hi HTH, The code worked great, however, it does not allowed me to add labels like before. My previous code was : figure hold subplot(1,3,1) boxplot([M_GO M_NOGO3], 'notch';'on';...     'labels';{'Go','No Go'})         ylabel('Reaction Time(ms)')         xlabel('GO vs NOGO')         title('GO vs NOGO RT Anova')                   Adapting it to your solution it now reads as: figure hold subplot(1,3,1) hold group = [ones(size(M_GO)); ones(size(M_NOGO3))+1]; x = cat(1,M_GO,M_NOGO3); boxplot(x,group), ...        'labels';{'Go','No Go'};         ylabel('Reaction Time(ms)')         xlabel('GO vs NOGO')         title('GO vs NOGO RT Anova') %%%However, my labels still only show 1 and 2 %%%% Could you help me to solve this minor problem, please? Thank you. "Anon" wrote in message ... > Hi Valentina, > > try following: > group = [ones(size(t1);ones(size(t2))+1;ones(size(t3))+2]; > x = cat(1,t1,t2,t3); > boxplot(x,group); > > HTH > > > > "Valentina " wrote in message ... > > Hi, > > I would like to create a box plot of my samples, but these samples have different sizes. I can combine all the samples in just one vector and then use grouping variables, but I don't understand how they work. so for example, if I have 3 samples t1,t2 and t3 of lengths 43,148,228 respectively, how would the function boxplot be filled in? Something like boxplot(cat(1,t1,t2,t3),....)? > > > > Thank you very much! > > > > Valentina
 Subject: boxplot, grouping variables From: Mats Date: 9 May, 2012 13:00:07 Message: 6 of 8 I hope you still have some use with this answer! set(gca,'XTick',1:3,'XTickLabel',{'label1';'label2';'label3'}) "Aldo Amaya" wrote in message ... > Hi HTH, > > The code worked great, however, it does not allowed me to add labels like before. > > My previous code was : > > figure > hold > subplot(1,3,1) > boxplot([M_GO M_NOGO3], 'notch';'on';... > 'labels';{'Go','No Go'}) > ylabel('Reaction Time(ms)') > xlabel('GO vs NOGO') > title('GO vs NOGO RT Anova') > > > > > > > Adapting it to your solution it now reads as: > > figure > hold > subplot(1,3,1) > hold > group = [ones(size(M_GO)); ones(size(M_NOGO3))+1]; > x = cat(1,M_GO,M_NOGO3); > boxplot(x,group), ... > 'labels';{'Go','No Go'}; > ylabel('Reaction Time(ms)') > xlabel('GO vs NOGO') > title('GO vs NOGO RT Anova') > > %%%However, my labels still only show 1 and 2 %%%% > > > > Could you help me to solve this minor problem, please? Thank you. > > > "Anon" wrote in message ... > > Hi Valentina, > > > > try following: > > group = [ones(size(t1);ones(size(t2))+1;ones(size(t3))+2]; > > x = cat(1,t1,t2,t3); > > boxplot(x,group); > > > > HTH > > > > > > > > "Valentina " wrote in message ... > > > Hi, > > > I would like to create a box plot of my samples, but these samples have different sizes. I can combine all the samples in just one vector and then use grouping variables, but I don't understand how they work. so for example, if I have 3 samples t1,t2 and t3 of lengths 43,148,228 respectively, how would the function boxplot be filled in? Something like boxplot(cat(1,t1,t2,t3),....)? > > > > > > Thank you very much! > > > > > > Valentina
 Subject: boxplot, grouping variables From: Ruth Date: 21 Jun, 2012 18:22:06 Message: 7 of 8 Hi, I tried this and I had an error, for example: x1 = [5 1 100 1]; x2 = [6 1 100 1 2 3]; group = [ones(size(x1));ones(size(x2))+1]; x = cat(1,x1,x2); boxplot(x,group); the error I get is CAT arguments dimensions are not consistent. Error in ==> ACCEPTEDRECOMMENDATIONSPERWEEKBOXPLOT at 56 group = [ones(size(x1));ones(size(x2))+1]; "Anon" wrote in message ... > Hi Valentina, > > try following: > group = [ones(size(t1);ones(size(t2))+1;ones(size(t3))+2]; > x = cat(1,t1,t2,t3); > boxplot(x,group); > > HTH > > > > "Valentina " wrote in message ... > > Hi, > > I would like to create a box plot of my samples, but these samples have different sizes. I can combine all the samples in just one vector and then use grouping variables, but I don't understand how they work. so for example, if I have 3 samples t1,t2 and t3 of lengths 43,148,228 respectively, how would the function boxplot be filled in? Something like boxplot(cat(1,t1,t2,t3),....)? > > > > Thank you very much! > > > > Valentina
 Subject: boxplot, grouping variables From: Steven_Lord Date: 22 Jun, 2012 13:39:54 Message: 8 of 8 "Ruth " wrote in message news:jrvooe\$d4g\$1@newscl01ah.mathworks.com... > Hi, I tried this and I had an error, for example: x1 = [5 1 100 1]; > x2 = [6 1 100 1 2 3]; > group = [ones(size(x1));ones(size(x2))+1]; > x = cat(1,x1,x2); > boxplot(x,group); > > the error I get is CAT arguments dimensions are not consistent. > > Error in ==> ACCEPTEDRECOMMENDATIONSPERWEEKBOXPLOT at 56 > group = [ones(size(x1));ones(size(x2))+1]; You're trying to stack a 1-by-4 vector of 1's on top of a 1-by-6 vector of 2's. MATLAB matrices must be rectangular; you can't have one row with 4 columns and another with 6. If you placed the 1-by-4 vector of 1's NEXT TO the 1-by-6 vector of 2's as opposed to ON TOP OF it, the result would be a 1-by-10 vector whose first 4 elements were 1 and whose last 6 elements were 2. A 1-by-10 vector is rectangular, and so that would work just fine. group = [ones(size(x1)),ones(size(x2))+1]; A similar problem occurs on the line where you construct x, and the solution is the same. -- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com

### Everyone's Tags:

Separated by commas
Ex.: root locus, bode

### What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.