matlab中boxplot函数的参数设置_如何改变内置Matlab boxplot函数的百分比值?

您可以通过修改图形对象的属性(而不是修改函数本身)来更改boxplot显示数据/分位数的方式。

这是一段代码,它将修改用于蓝框的分位数(最初,蓝框对应于.25和.75分位数,并将更改为.1和.9)。上/下晶须的基部将相应地改变。请注意,胡须的尖端不变(它们仍然对应于四分位数范围的1.5)。你可以改变胡须的提示,就像我们改变他们的基础部分一样。

%%% load some data

load carsmall

MPG = MPG(ismember(Origin,'USA','rows'));

Origin = Origin(ismember(Origin,'USA','rows'),:)

Origin(isnan(MPG),:) = [];

MPG (isnan(MPG),:) = [];

%%% quantile calculation

q = quantile(MPG,[0.1 0.25 0.75 0.9]);

q10 = q(1);

q25 = q(2);

q75 = q(3);

q90 = q(4);

%%% boxplot the data

figure('Color','w');

subplot(1,2,1);

boxplot(MPG,Origin);

title('original boxplot with quartile', 'FontSize', 14, 'FontWeight', 'b', 'Color', 'r');

set(gca, 'FontSize', 14);

subplot(1,2,2);

h = boxplot(MPG,Origin) %define the handles of boxplot

title('modified boxplot with [.1 .9] quantiles', 'FontSize', 14, 'FontWeight', 'b', 'Color', 'r');

set(gca, 'FontSize', 14);

%%% modify the figure properties (set the YData property)

%h(5,1) correspond the blue box

%h(1,1) correspond the upper whisker

%h(2,1) correspond the lower whisker

set(h(5,1), 'YData', [q10 q90 q90 q10 q10]);% blue box

upWhisker = get(h(1,1), 'YData');

set(h(1,1), 'YData', [q90 upWhisker(2)])

dwWhisker = get(h(2,1), 'YData');

set(h(2,1), 'YData', [ dwWhisker(1) q10])

%%% all of the boxplot properties are here

for ii = 1:7

ii

get(h(ii,1))

end以下是结果。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值