Borrar filtros
Borrar filtros

Boxplots for groups of data

2 visualizaciones (últimos 30 días)
Andreas
Andreas el 17 de Abr. de 2014
Respondida: Star Strider el 17 de Abr. de 2014
I am trying to plot some boxplots using the grouping variable but I am having little success so far. Perhaps someone can point me into the right direction.
I have
X = zeros(10,4); X(:,1) = rand(10,1); X(:,2) = rand(10,1); X(:,3) = rand(10,1); X(:,4) = rand(10,1);
boxplot(X);
which produces one box plots for each column of X. That works.
Now I want to group the boxplots such that group 1 consists of the first to columns of X and group 2 of the last 2 columns of X.
How can I do that?
The man page says "Grouping variables must have one row per element of X, or one row per column of X." but when I do that I get an error saying: "X must be a vector when there is a grouping variable."

Respuestas (1)

Star Strider
Star Strider el 17 de Abr. de 2014
The reshape function is your friend here. Create a (20x2) matrix Z from your (20x4) matrix X:
X = rand(10,4)
Z = reshape(X,[],2)
then use Z as your data matrix.

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by