Grouping multiple variables in boxplot with different numbers of samples
Show older comments
Hi - I have n-by-m data where n is the number of datapoints and m is the number of variables.
I have an additional vector, length n, containing 0s and 1s. The 0s refer to which datapoints are controls and experimental conditions, respectively.
My data is a matrix with n = 43 datapoints and m = 15 variables.
I would like to plot paired boxplots, such as this example from the Mathematics Stack Exchange (https://mathematica.stackexchange.com/questions/66720/how-to-group-box-and-whisker-in-parallel-for-comparison-in-boxwhiskerchart):

Basically, I'm trying to plot 15 variables with two boxes each (A,B,C,.. in the image above), one for control and one for experimental condition for each variable (Apples and Oranges in the image above).
To play around, I tried the following:
X = randn(43,15); % Sample data - 43 points, 15 vars
group = randi([0,1],43,1); % Vector of length 43, 0 = control, 1 = exp
boxplot(X,group)
It seems to be assuming for a matrix input that different columns of X are different groups, but the different groups are within the columns of X, represented by the group var.
I feel like I'm missing something very basic here, but I'm sleep-deprived and not seeing it. (Please note also that I am currently limited to functionality in R2018b.)
Any help would be much appreciated. TYIA!
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

