How to make a box plot with a scatter plot overlay with uneven data sets

30 ビュー (過去 30 日間)
Elizabeth
Elizabeth 2023 年 7 月 19 日
回答済み: Angelo Yeo 2023 年 7 月 20 日
As the title states, I would like to make a box plot using two different mean from uneven data sets. I would also like to overlay the bars with a scatter plot of the individual data. Can someone please help me?

回答 (1 件)

Angelo Yeo
Angelo Yeo 2023 年 7 月 20 日
I'm not sure what you want. However, consider using hold on in order to overlay multiple plots on an axis.
x1 = ones(1,100);
x2 = 2 * ones(1,100);
x3 = 3 * ones(1,100);
y1 = 2 * randn(1,100);
y2 = [randn(1,50) randn(1,50) + 4];
y3 = 5 * randn(1,100) + 5;
%% plotting
h = boxplot([y1, y2, y3], [x1, x2, x3]);
set(h, {'linew'},{2})
hold on
swarmchart(x1,y1,5)
swarmchart(x2,y2,5)
swarmchart(x3,y3,5)
hold off

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by