How to use 'factorgap' to set larger gaps between groups of boxplot.
古いコメントを表示
Dear Community,
I am using the below code to combine boxplot with scatter plot. I am wondering, how to use the 'factorgap' to have every boxes in a kind of groups of two, that is, larger gap after every second ones.
I appreciate your suggestions!
Regards
lg
h=boxplot(vertcat(C{:}),grp,'symbol','','Colors','k');
set(h,'LineWidth',1.5)
lines = findobj(gcf, 'type', 'line', 'Tag', 'Median');
set(lines, 'Color', 'r');
hold on
scatter(grp,data_for_scatter,'.','k','jitter','on', 'jitterAmount',0.1);
ps: Please find the example data attached!
3 件のコメント
Levente Gellért
2021 年 7 月 26 日
Scott MacKenzie
2021 年 7 月 26 日
From the boxplot documentation:
- 'FactorGap' represents the distance of the gap between different factors of a grouping variable, expressed as a percentage of the width of the plot.
So, in my answer I used "15", which corresponds to 15% of the width of the plot. So, you can see extra spacing between between the three groups of two boxes for the g1 group variable.
Once you get things set up with the extra group variable, you'll need to play with this value until you get the spacing you want.
Levente Gellért
2021 年 7 月 26 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
