boxplotの中央​値の消去&ひげを実線​にする方法

15 ビュー (過去 30 日間)
Ohashi Asuka
Ohashi Asuka 2020 年 3 月 24 日
コメント済み: Ohashi Asuka 2020 年 3 月 27 日
タイトルの通りですが,boxplotのオプションの設定方法が分かりません.
boxplotの中央値の消去(白線でもOK)し,ひげを実線にしたいです.
boxplot(x,'PlotStyle','compact')とすると,実線のひげの箱ひげ図が書けますが,
今回はボックス自体は元のままにしたいので,('PlotStyle','compact')は使えません.

採用された回答

Kenta
Kenta 2020 年 3 月 25 日
clear;clc;close all
rng default
x = randn(100,10);
f=figure
xx=[1:10];
boxplot(x,'positions',xx)
% Find handle for median line and set visibility off
h = findobj(gca,'Tag','Median');
set(h,'Visible','off');
こんにちは、findobj関数で、中央値を参照し、visible => offとすると、以下のようになります。ただ、破線を実線にする方法はわかりませんでした。
  2 件のコメント
Akira Agata
Akira Agata 2020 年 3 月 25 日
編集済み: Akira Agata 2020 年 3 月 25 日
こんにちは。Kentaさんご指摘のとおり、まずfindobj関数を使って対象となるラインオブジェクトを抽出したうえで、プロパティ値(今回のケースでは 'LineStyle' など)を調整することで実現可能です。一例を以下に示します。
% Sample data
rng('default');
x = randn(100,2);
% Boxplot
figure
boxplot(x)
% Set 'Median' line style
h = findobj(gca,'Tag','Median');
set(h,'LineStyle','none');
% Set 'Upper/Lower Whisker' line style
h = findobj(gca,'Tag','Lower Whisker','-or','Tag','Upper Whisker');
set(h,'LineStyle','-');
Ohashi Asuka
Ohashi Asuka 2020 年 3 月 27 日
Kentaさん,Akira Agataさん,ご回答ありがとうございます.
とても分かりやすく教えてくださり,助かりました.

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

その他の回答 (0 件)

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!