matlab绘制误差棒

在这里插入图片描述

set(0,'defaultfigurecolor','w')
 
%errorbar函数实例
figure;
subplot(2,2,1);
%横轴
x = 1:10:100;
%均值
y = [20 30 45 40 60 65 80 75 95 90];
%标准差
err = 8*ones(size(y));
%线型,颜色,线宽,标记大小
errorbar(x,y,err,'-*b','LineWidth',1','MarkerSize',8) 
xlabel('Time');ylabel('Production');
%设置坐标轴字体大小粗细,字体样式以及横纵轴范围
set(gca,'fontsize',10,'fontweight','bold','FontName','Times New Roman','XLim',[0,120],'YLim',[0,120]);
  
subplot(2,2,2);
x = 1:10:100;
y = [20 30 45 40 60 65 80 75 95 90];
err1 = 10*ones(size(y));
err2 = 10*rand(size(y));
errorbar(x,y,err1,err2,'*b','LineWidth',1','MarkerSize',8) 
xlabel('Time');ylabel('Production');
title('标题','fontsize',10,'fontweight','bold');
%设置坐标轴字体大小粗细,字体样式以及横纵轴范围
set(gca,'fontsize',10,'fontweight','bold','FontName','Times New Roman','XLim',[0,120],'YLim',[0,120]);
 
subplot(2,2,3)
Average1=[12,11,7,7,6,5];
Variance1=[0.5,0.4,0.3,1,0.3,0.5];     %A地的数据
Average2=[10,8,5,4,3,3];
Variance2=[0.4,0.3,0.4,0.6,0.3,0.5];    %B地的数据
Time=1:1:6;
errorbar(Time,Average1,Variance1,'r-o')    %A地误差棒图,用红色线表示
hold on
errorbar(Time,Average2,Variance2,'b-s')    %B地误差棒图,用蓝色线表示
xlabel('Time');ylabel('Production');
 
subplot(2,2,4);
Average2=[120,110,70,70,60,50];
Variance2=[15,14,8,10,9,9];     %A地的数据
Average3=[100,80,50,40,30,30];
Variance3=[14,8.3,9.4,10.6,13,15];    %B地的数据
Time=1:1:6;
errorbar(Time,Average2,Variance2,'ro')    %A地误差棒图,用红色线表示
hold on
errorbar(Time,Average3,Variance3,'bs','MarkerSize',10,...
    'MarkerEdgeColor','red','MarkerFaceColor','red')    %B地误差棒图,用蓝色线表示
xlabel('Time');ylabel('Production');
set(gca,'fontsize',10,'fontweight','bold','FontName','Times New Roman','XLim',[0,8],'YLim',[0,140]);
grid on;
  • 3
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值