How to make a box plot with a scatter plot overlay with uneven data sets
31 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Angelo Yeo
on 20 Jul 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
0 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!