フィルターのクリア

How to align XTicks with boxplots, code and the output is attached ?

8 ビュー (過去 30 日間)
Avijit Paul
Avijit Paul 2023 年 4 月 29 日
編集済み: Cris LaPierre 2023 年 4 月 30 日
rmse1=[rmse_wavelet_anfis_his;rmse_wavelet_anfis;rmse_QDM_his;rmse_QDM;...
rmse_QM_his;rmse_QM;rmse_raw_his;rmse_raw];
mae1=[mae_wavelet_anfis_his;mae_wavelet_anfis;mae_QDM_his;mae_QDM;...
mae_QM_his;mae_QM;mae_raw_his;mae_raw];
g = ones(size(rmse_raw));
g = [g;g*2;g*3;g*4;g*5;g*6;g*7;g*8];
g=categorical(g);
p= tiledlayout(1,2,'TileSpacing','none');
ax1 = nexttile;
b1= boxchart(ax1,g,rmse1,'GroupByColor',g,'BoxWidth',3);
ax2=nexttile;
b2= boxchart(ax2,g,mae1,'GroupByColor',g,'BoxWidth',3);
for i=1:8
remaind=rem(i,2);
if remaind==1
b1(i).SeriesIndex=1;
b2(i).SeriesIndex=1;
else
b1(i).SeriesIndex=2;
b2(i).SeriesIndex=2;
end
end

採用された回答

Cris LaPierre
Cris LaPierre 2023 年 4 月 29 日
編集済み: Cris LaPierre 2023 年 4 月 30 日
When you group by color, boxchart expects there to be a boxplot for each group at each tick. It therefore makes space for that, centering the grouped boxplots around each tick.
If you want to set the color for each boxchart and have it aligned with an xtick, you must plot each boxplot individually, as Adam Danz shows in the linked answer.
  1 件のコメント
Avijit Paul
Avijit Paul 2023 年 4 月 30 日
Thanks a lot. Matlab can update the boxchart function, for this scenario that, whenever there is one boxchart for one xtick, it can automatically allign with the xticks.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by