Matlab箱线图分组叠加折线图

该博客介绍了如何在Matlab中创建分组箱线图,并在其上叠加折线图来展示不同组别的平均值和中位数。通过设置颜色、宽度和位置,使得箱线图和折线图清晰地呈现了三个地区(农村、CZ、QT)的数据变化。同时,使用legend、xlabel、ylabel和title进行图例、标签和标题的设定,增强了图表的可读性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

%分组group箱线图和折线图的合并版本

%% clear data

%% edge color

edgecolor1=[0.8,0.8,0.8]; % white color:[1,1,1],如果设置成了白色就没有箱子线图边框

edgecolor2=[0.8,0.8,0.8]; % white color

edgecolor3=[0.8,0.8,0.8]; % white color

position_1 = [0.8:1:4.8]; % define position for first group boxplot

position_2 = [1.0:1:5.0]; % define position for second group boxplot

position_3 = [1.2:1:5.2]; % define position for second group boxplot

%分别农村箱线图和对应平均值和中位数的折线图,注意boxplot当有横坐标还想设置位置时用position

figure(2)

box_1 = boxplot(CALCULATE_data_nc,t_nc,'positions',position_1,'colors', ...

edgecolor1,'width',0.1,'notch','on','symbol','');

hold on;

p1=plot(position_1,mean_nc,'o',position_1,med_nc,'-')

p1(2).LineWidth = 1;%set median linewidth to 1

p1(2).Color = [.6,.1,.3];p1(1).Color = [.6,.1

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Geo_NaNa

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值