Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Boxplot several datasets
Replies: 3   Last Post: Nov 20, 2012 3:19 AM

 Messages: [ Previous | Next ]
 Ruben Posts: 16 Registered: 6/17/10
Re: Boxplot several datasets
Posted: Nov 20, 2012 3:19 AM

Thank you Tom,

this is exactly what I needed a simple example to get started.

All the best

"Tom Lane" <tlane@mathworks.com> wrote in message <k8do5k\$plv\$1@newscl01ah.mathworks.com>...
> > I would like to plot several boxplots in the same figure for different
> > datasets. For example:

> ...
> > I also would like to have the boxes in different colours or shapes. Is
> > this possible?

>
> There are many related options in the boxplot function. Type "help boxplot",
> and try this to get you started:
>
> x1 = rand(20,6);
> x2 = .5+rand(20,6);
> x3 = randn(20,6);
>
> x = [x1;x2;x3]; x = x(:);
> g1 = [ones(size(x1)); 2*ones(size(x2)); 3*ones(size(x3))]; g1 = g1(:);
> g2 = repmat(1:6,60,1); g2 = g2(:);
>
> boxplot(x, {g2,g1}, 'colorgroup',g1, 'factorgap',5, 'factorseparator',1)
>
> -- Tom

Date Subject Author
11/16/12 Ruben
11/17/12 Ruben
11/19/12 Tom Lane
11/20/12 Ruben