The original boxplot.m function is more heavy-handed than most Matlab plotting functions; it replaces ticks with text labels, changes axis dimensions, etc. This version creates a boxplot with a minimal amount of alteration to existing axes, assuming that any cosmetic changes (color, tick labels, line specs, etc) can be added by the user afterwards if necessary.
Additionally, this function allows one to create clustered boxplots, similar to an unstacked bar graph.
Kelly Kearney (2021). boxplot2 (https://github.com/kakearney/boxplot2-pkg), GitHub. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
Is there a possibility to add a legend for each group?
Filling the dataset with NaN works as expected.
Thank you Kelley. :-)
@Jan and Peter, This function ignores NaNs, so you could add NaNs to your shorter datasets to allow the concatenation needed for this utility. Or alternatively, perhaps the original boxplot with the group input would better suit your needs.
@Peter,
Did you find any solution for your groups with different numbers of observations?
This would be really interesting.
Thanks in advance,
Jan
Is there are way to do this for groups with different numbers of observations?
Thanks so much.
Peter
Is there a way that I can change the linestyle of the box?Thanks a lot
@Stephanie,
The tick labels can be altered via standard Matlab syntax, e.g.
set(gca, 'xticklabel', '')
will remove remove tick labels. Or you can use a combo of the XTick and XTickLabel properties to assign specific tick locations and labels.
Overall really appreciate this function as it grouped the boxplots exactly as I needed them.
Is there an easy way to get rid of the numeric x labels? It would make more sense to remove them if comparing numerous pair-wise boxplots within the same figure.