Box plot for each cell of a cell array all on one figure

5 visualizzazioni (ultimi 30 giorni)
I want to make a figure of box plots where each box corresponds to the data in one cell of a cell array. Generally, this will mean about 14 boxes in one figure. I can easily make on box plot from one cell of data using
boxplot(tmp_indiv{1,1})
but because the length of my cell arrays are constantly changing, I cannot use something like
boxplot(top_five_precip_a{:})
I have far too many cell arrays to do this individually. Furthermore, I want to change the whisker length so that all box plots will have whiskers to the 95th percentile as opposed to the default, which I believe I've done using
boxplot(tmp_indiv{1,1}, 'whisker', 0.7193)
but I'm not 100% sure that its correct.
Any help would be greatly appreciated. Thanks!

Risposte (1)

Ameer Hamza
Ameer Hamza il 28 Mag 2018
Try this
% creating sample dataset
tmp_indiv{1} = 1:10;
tmp_indiv{2} = 11:30;
tmp_indiv{3} = 31:40;
y = num2cell(1:numel(tmp_indiv));
x = cellfun(@(x, y) [x(:) y*ones(size(x(:)))], tmp_indiv, y, 'UniformOutput', 0); % adding labels to the cells
X = vertcat(x{:});
boxplot(X(:,1), X(:,2))

Categorie

Scopri di più su Graphics Objects in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by