matlab怎么画箱线图群,[转载]Matlab如何画箱线图群组

data = rand(20,24)

month = repmat({'jan' 'feb' 'mar' 'apr'

'may' 'jun' 'jul' 'aug' 'sep' 'oct' 'nov' 'dec'},1,2);

simobs =

[repmat({'sim'},1,12),repmat({'obs'},1,12)];

boxplot(data,{month,simobs},'colors',repmat('rb',1,12),'factorgap',[5

2],'labelverbosity','minor');

另一种方法是利用不同坐标使用hold on在同一幅图上画箱线图

% Boxplot for the observed temperature

from January to December

Temp_O = [Jan_O, Feb_O, Mar_O, Apr_O,

May_O, Jun_O, Jul_O, Aug_O, Sep_O, Oct_O, Nov_O, Dec_O];

position_O =

1:1:12;

% Define position for 12 Month_O

boxplots

box_O =

boxplot(Temp_O,'colors','b','positions',position_O,'width',0.18);

set(gca,'XTickLabel',{' '}) %

Erase xlabels

hold on % Keep the

Month_O boxplots on figure overlap the Month_S

boxplots

% Boxplot for the simulated temperature

from January to December

Temp_S = [Jan_S, Feb_S, Mar_S, Apr_S,

May_S, Jun_S, Jul_S, Aug_S, Sep_S, Oct_S, Nov_S, Dec_S];

position_S =

1.3:1:12.3; % Define position for 12 Month_S

boxplots

box_S =

boxplot(Temp_S,'colors','r','positions',position_S,'width',0.18);

hold

off % Insert texts and

labels

a4c26d1e5885305701be709a3d33442f.png

以上两种方法均可画多组的箱线图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值