Plotting Multiple Box plot in same graph same x axis
古いコメントを表示
I have a data for 5 samples, and for 3 months.
I want to plot 5 box plots for every months. Which means in X-axis I will have January, Mars and April (3 values).
And I want to plot the 5 boxes plot in each month (different color ofc).
I search in the web and unfortunaly I didn't find any case like this, I don't know if it's possible to plot something like that.
採用された回答
その他の回答 (1 件)
You can group them in bins from 1 to 15 and tweak the x labels to match your needs.
See the documentation for how to use 'GroupByColor'.
data=cell(5,3);
for n=1:numel(data)
data{n}=randi(n)*randn(100,1);
end
grouping=cell(size(data));
for n=1:numel(data)
grouping{n}=n*ones(size(data{n}));
end
grouping=[grouping{:}];
data=[data{:}];
boxchart(grouping(:),data(:))
xticks(2.5:5:12.5)
xticklabels({'January','March','April'})
4 件のコメント
Tesla
2022 年 2 月 25 日
A cursory look at the documentation suggests that this shouldn't be too difficult. Did you try anything?
sample=cell(5,3);
for n_month=1:3
for n_sample=1:5
sample{n_sample,n_month}=n_sample*ones(size(data{n_sample,n_month}));
end
end
sample=[sample{:}];sample=sample(:);
,'GroupByColor',sample
Tesla
2022 年 2 月 26 日
Rik
2022 年 2 月 26 日
The point is that each variable should be a vector. The best syntax to ensure that depends on your exact data.
Also, if this answer solved the problem, please consider marking it as accepted answer.
カテゴリ
ヘルプ センター および File Exchange で Descriptive Statistics and Visualization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






