How do I create a beeswarm plot and boxplot together?

6 Ansichten (letzte 30 Tage)
fz
fz am 28 Jul. 2022
Bearbeitet: dpb am 28 Jul. 2022
I need to create a plot similar to the figure below

Antworten (1)

dpb
dpb am 28 Jul. 2022
Bearbeitet: dpb am 28 Jul. 2022
The basic starting point isn't difficult; some tedium in setting all the conditional fixups of symbols, colors, etc, etc., ... but start with
hBXP=boxplot(x);
hold on
ylim([1/100 100])
hAx=gca;
hAx.YScale='log';
hL=plot(x,'.');
This will put the data on top of the boxplot and return an array hL of line handles, one for each column in x-- you'll have to set each line handle line color, marker, etc., to suit. This can be done with predefined constants as cell arrays for some ease in coding.
The nicety the above doesn't handle is adding "jitter" to the x-axis positions of the data -- I presume that is simply randomized in the given figure, there aren't actual varying data values are there?
I recall a Q? on forum about doing so in the not too distant past, but I can't think of a specific way to find it at the moment...

Community Treasure Hunt

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

Start Hunting!

Translated by