- 积分
- 72
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-12-31
- 最后登录
- 1970-1-1

|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 HJY@E 于 2022-4-24 00:05 编辑
利用area函数绘制最值区间及平均值,MARK一下,便于大家和自己今后使用。
效果图如下:
最值区间及平均值
附程序如下
- x=datetime(2017,1,15):calmonths(12):datetime(2021,1,15); %设置起始年月日,间隔月数,结束年月日;
- year=[0.3718 2.2913 1.2674;0.7051 2.062 1.3405;0.5273 2.0061 1.2386;0.3688 2.1685 1.1438;0.4966 1.823 1.0845];%最值序列
- p1=area(x,year(:,2),"FaceColor",'cyan','EdgeColor','none');%设置填充面色及边框色
- alpha(p1,.05);%设置填充面的透明度
- hold on
- area(x,year(:,1),"FaceColor",'white','EdgeColor','none');%设置填充面色及边框色
- p2=plot(x,year(:,3),"LineWidth",2,"Color",'b','DisplayName','平均值');
- p3=plot(x,year(:,1),"LineWidth",1,"Color",'k','Marker','.','DisplayName','最小值');
- p4=plot(x,year(:,2),"LineWidth",1,"Color",'k','Marker','o','DisplayName','最大值');
- hold off
- title('xxx 2017 to 2021');%图名
- xlabel('Years')
- ylabel('xxx')
- lgd = legend([p2 p3 p4],'Location','eastoutside');%legend([p1 p3],{'First','Third'})
- title(lgd,'图例')%图例名
- xlim([min(x),max(x)]);%设置x轴范围
- xticks(x);%设置x轴刻度
复制代码
|
|