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

30 visualizaciones (últimos 30 días)
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?

Respuestas (1)

Angelo Yeo
Angelo Yeo el 20 de Jul. de 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

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by