フィルターのクリア

Hi, is it possible to change the width of a box in boxplot if 'BoxStyle' is set to 'filled'?

65 ビュー (過去 30 日間)
Rebecca Ward
Rebecca Ward 2016 年 3 月 18 日
コメント済み: Ben Oeveren 2021 年 6 月 2 日
I have tried using 'Widths' but it doesn't seem to have any effect on the boxes themselves? Thanks, Rebecca
  3 件のコメント
Tejas
Tejas 2016 年 3 月 22 日
>> boxplot(MPG)
>> boxplot(MPG, 'Widths',34)
This works for me. Please do share your code.
MNouv
MNouv 2017 年 9 月 25 日
Hello, I see that this post has not been solved and I have the same problem. The 'widths' command only changes the size of the median line, not of the box itself... Any idea how to fix this?

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

回答 (1 件)

Giorgio Mirone
Giorgio Mirone 2017 年 11 月 15 日
Try this:
a = get(get(gca,'children'),'children'); % Get the handles of all the objects
t = get(a,'tag'); % List the names of all the objects
idx=strcmpi(t,'box'); % Find Box objects
boxes=a(idx); % Get the children you need
set(boxes,'linewidth',10); % Set width
  1 件のコメント
Ben Oeveren
Ben Oeveren 2021 年 6 月 2 日
Or you can make a Patch on the same position. I find that more convienient. It is a same that Matlab has not used a Patch in the first place. It would improve the posibilities.
box_h = findobj(hb2,'Tag','Box');
for i = 1:length(box_h)
hp(i) = patch([box_h(i).XData],[box_h(i).YData],colors(i,:),'FaceAlpha',.2);
end
uistack(box_h,'bottom')

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by