BoxChart box position doesnt match xaxis label when 'groupbycolor'

17 ビュー (過去 30 日間)
Danylyna Shpakivska
Danylyna Shpakivska 2022 年 7 月 21 日
編集済み: Adam Danz 2022 年 11 月 17 日
how to align xaxes label when using groupbycolor' option in boxchart?
as you can see on the web example xaxes isnt alignied to each boxplot.
the same appens in my boxchart.
how to solve it? thanks in advance
  2 件のコメント
dpb
dpb 2022 年 7 月 21 日
It's centered on the group; you don't have both colors in all groupings so it's an optical delusion at RHS of example...yours has only one for all groupings.
Danylyna Shpakivska
Danylyna Shpakivska 2022 年 7 月 21 日
So the problem is that i dont have de same number of categories on xgroup data than on cgroupdata?
Anyway, there is somo way to adjust the xaxis manually? for example, getting the position of each boxchar? how can I access to that?
Thanks

サインインしてコメントする。

採用された回答

Adam Danz
Adam Danz 2022 年 7 月 21 日
The example you shared from the documentation (link) uses grouped data. Groups are centered around the x-ticks. If you are missing members of group, the missing groups will appear as empty space.
If I add vertical grid lines and expand the image, this is easier to see.
I have a feeling you're also using grouped data to control the colors of your boxplots and your missing groups appear as empty space.
  4 件のコメント
Danylyna Shpakivska
Danylyna Shpakivska 2022 年 11 月 17 日
Y=[T.number_events];
xgroupdata = T.roi_label.*T.roi_hemis; % These are my xtick categories ("labels")
figure
set(gcf, 'Position', [380,258,1250,500])
plot_alpha=boxchart(xgroupdata,Y,'Notch','on','GroupByColor',categorical(T.group_subj));
% "T.group_subj" is the variable that groups by color.
legend
title(sprintf('%s Events',freq_band))
xlabel('Groups per ROI')
ylabel('Number of Events (Median)')
---------------------------------
The variable to group by color (legend) should be provided as other entry to the boxchart function. I hope it helps you.
Adam Danz
Adam Danz 2022 年 11 月 17 日
編集済み: Adam Danz 2022 年 11 月 17 日
@Alejandro Nogueron Aramburu, follow this example from the documentation. Group by cgroupdata. You can ignore the last line of code in the example - that line shows how to change a box color.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by