Effacer les filtres
Effacer les filtres

anova1関数で出​る規定の箱ひげ図のデ​ザインを変えることは​できますか?

5 vues (au cours des 30 derniers jours)
KO
KO le 10 Déc 2023
Commenté : KO le 20 Déc 2023
図のようにタイトルや軸のプロパティは変更できますが、箱ひげ図の色や、外れ値の除外などができません。
方法をご教授いただければ幸いです。

Réponses (1)

Atsushi Ueno
Atsushi Ueno le 17 Déc 2023
Modifié(e) : Atsushi Ueno le 17 Déc 2023
anova1 関数は内部で boxplot 関数を使って箱ひげ図を表示しますが、グラフィックオブジェクトハンドルで描画内容を調整するのは困難なので、これを使わない回避方法を取ります。
代わりに boxchart 関数で表示後、下記リンク先のパラメータを変更すればやりたい事が出来ます。
% サンプルデータ引用先:https://jp.mathworks.com/help/stats/anova1.html#brx09p9-27
strength = [82 86 79 83 84 85 86 87 74 82 78 75 76 77 79 79 77 78 82 79];
alloy = {'st','st','st','st','st','st','st','st',...
'al1','al1','al1','al1','al1','al1',...
'al2','al2','al2','al2','al2','al2'};
xgroupdat = categorical(alloy);
[p,tbl,stats] = anova1(strength,alloy,'off'); % 'off': ANOVA 表と箱ひげ図を表示しない
figure;
b = boxchart(xgroupdat,strength);
b.BoxFaceColor = [0 0.5 0]; % ボックスの色
b.MarkerStyle = "none"; % 外れ値スタイル (none:表示しない)
% b.JitterOutliers = true; % 外れ値マーカー変位 (表示しないからどっちでもいい)
b.Orientation = "vertical"; % ボックス チャートの方向
b.Notch = true; % 中央値比較表示 (true:凹ませる)
  3 commentaires
Atsushi Ueno
Atsushi Ueno le 17 Déc 2023
> anova1関数で出​る規定の箱ひげ図のデ​ザインを変えることは​できますか?
肝心の質問に回答していませんでしたが、それはできます。
可能か不可能かでいうと可能なのですが、なぜか boxplot 関数による描画後にグラフィックハンドルを取得してプロパティを変更しようとしてもそれができず、グラフィックプリミティブオブジェクト、即ち箱ひげ図を構成する線1本1本を変更する必要があったりします。一方 boxchart 関数の方は他のプロット関数と同様に描画後にグラフィックハンドルを取得してプロパティを変更することができます。
これが何故なのかは謎です。
KO
KO le 20 Déc 2023
いつもありがとうございます。boxplotが編集しづらいということがよくわかりました。boxchartを使用してうまくいきました。調べていただき大変ありがとうございました。

Connectez-vous pour commenter.

Catégories

En savoir plus sur グラフィックス オブジェクトのプログラミング dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!