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!