Box plot for each cell of a cell array all on one figure
5 ビュー (過去 30 日間)
古いコメントを表示
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!
0 件のコメント
回答 (1 件)
Ameer Hamza
2018 年 5 月 28 日
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))
3 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!