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

30 vues (au cours des 30 derniers jours)
Elizabeth
Elizabeth le 19 Juil 2023
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?

Réponses (1)

Angelo Yeo
Angelo Yeo le 20 Juil 2023
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

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by