立即注册 登录
气象家园 返回首页

meteowang的个人空间 http://bbs.06climate.com/?131856 [收藏] [复制] [分享] [RSS]

日志

MATLAB画折线图+子图

已有 13 次阅读2024-3-7 13:52




% % 创建一行4列的组图
figure(1);
% 第1个子图-----------------TTTTTTTTTTTT------------------------------------------
subplot(4, 1, 1);
plot(time, T_sim_xt,'color',color(1, :),'LineWidth',1.5);
hold on
plot(time, T_obs_xt,'o','MarkerSize',3,'color',color(2, :),'LineWidth',1.5);
%%%%%%%%%%%%%%%%%%设置图参数
set(gca,'YLim',[-10 20]);%Y轴的数据显示范围
set(gca,'YTick',[-10:5:20]);%Y轴的刻度值显示值
set(gca,'XTick',[1:48:288]);
set(gca,'XLim',[1 288]);%X轴的数据显示范围
set(gca,'XTickLabel',{' ','2019-01-03','2019-01-05','2019-01-07','2019-01-09','2019-01-11','2019-01-13'});
legend('\fontname{Times new roman}Simulation','\fontname{Times new roman}Observation','Location','Northwest','FontSize',14);
set(gca,'linewidth',0.7,'fontsize',14,'fontname','Times new roman')
ylabel('\fontname{Times new roman}T2m (℃)','FontSize',14,'Position', [-12, 4.5, 0]);
xlabel('\fontname{Times new roman}Datetime','FontSize',16);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%删除右上刻度线
box off     % 取消边框
ax1 = axes('Position', get(gca, 'Position'), 'XAxisLocation', 'top', 'YAxisLocation', 'right', 'Color', 'none', 'XColor', 'k', 'YColor', 'k');
set(ax1,'XTick', [],'YTick', []);   % 去掉xy轴刻度
hold off
set(0,'defaultfigurecolor','w');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%删除右上刻度线
title('XingTai-T2m','fontsize',14,'fontname','Times new roman');



% 第2个子图-------------RH RH RH RH----------------------------------------------------
subplot(4, 1, 2);
plot(time, RH_sim_xt','color',color(1, :),'LineWidth',1.5);
hold on
plot(time, RH_obs_xt,'o','MarkerSize',3,'color',color(2, :),'LineWidth',1.5);
%%%%%%%%%%%%%%%%%%设置图参数
set(gca,'YLim',[0 130]);%Y轴的数据显示范围
set(gca,'YTick',[0:25:100]);%Y轴的刻度值显示值
set(gca,'XTick',[1:48:288]);
set(gca,'XLim',[1 288]);%X轴的数据显示范围
set(gca,'XTickLabel',{' ','2019-01-03','2019-01-05','2019-01-07','2019-01-09','2019-01-11','2019-01-13'});
legend('\fontname{Times new roman}Simulation','\fontname{Times new roman}Observation','Location','Northwest','FontSize',14);
set(gca,'linewidth',0.7,'fontsize',14,'fontname','Times new roman')
ylabel('\fontname{Times new roman}RH (100%)','FontSize',14,'Position', [-12, 65, 0]);
xlabel('\fontname{Times new roman}Datetime','FontSize',16);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%删除右上刻度线
box off     % 取消边框
ax2 = axes('Position', get(gca, 'Position'), 'XAxisLocation', 'top', 'YAxisLocation', 'right', 'Color', 'none', 'XColor', 'k', 'YColor', 'k');
set(ax2,'XTick', [],'YTick', []);   % 去掉xy轴刻度
hold off
set(0,'defaultfigurecolor','w');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%删除右上刻度线
title('XingTai-RH','fontsize',14,'fontname','Times new roman');


[u,w] = size(V_sim_cm)
tt = [1:u]
% 第3个子图-------------Wind-----------------------------------------------
subplot(4, 1, 3);
plot(tt, V_sim_xt,'color',color(1, :),'LineWidth',1.5);
hold on
plot(tt, V_obs_xt,'o','MarkerSize',3,'color',color(2, :),'LineWidth',1.5);
% %%%%%%%%%%%%%%%%%%设置图参数
set(gca,'YLim',[0 15]);%Y轴的数据显示范围
set(gca,'YTick',[0:5:15]);%Y轴的刻度值显示值
set(gca,'XTick',[1:2:12]);
set(gca,'XLim',[1 12]);%X轴的数据显示范围
set(gca,'XTickLabel',{' ','2019-01-03','2019-01-05','2019-01-07','2019-01-09','2019-01-11','2019-01-13'});
legend('\fontname{Times new roman}Simulation','\fontname{Times new roman}Observation','Location','Northwest','FontSize',14);
set(gca,'linewidth',0.7,'fontsize',14,'fontname','Times new roman')
ylabel('\fontname{Times new roman}Wind (m/s)','FontSize',14,'Position', [0.5, 7.5, 0]);
xlabel('\fontname{Times new roman}Datetime','FontSize',16);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%删除右上刻度线
box off     % 取消边框
ax3 = axes('Position', get(gca, 'Position'), 'XAxisLocation', 'top', 'YAxisLocation', 'right', 'Color', 'none', 'XColor', 'k', 'YColor', 'k');
set(ax3,'XTick', [],'YTick', []);   % 去掉xy轴刻度
hold off
set(0,'defaultfigurecolor','w');
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%删除右上刻度线
title('XingTai-Wind','fontsize',14,'fontname','Times new roman');



[x,y] = size(rad_sim_xt)
tt = [1:x]
% rad_sim_xt
% 第4个子图-------------RAD------------------------------------------
subplot(4, 1, 4);
plot(tt, rad_sim_xt,'color',color(1, :),'LineWidth',1.5);
hold on
plot(tt, rad_obs_xt,'o','MarkerSize',3,'color',color(2, :),'LineWidth',1.5);
% %%%%%%%%%%%%%%%%%%设置图参数
set(gca,'YLim',[0 1404]);%Y轴的数据显示范围
set(gca,'YTick',[0:400:1200]);%Y轴的刻度值显示值
set(gca,'XTick',[1:12:96]);
set(gca,'XLim',[1 96]);%X轴的数据显示范围
set(gca,'XTickLabel',{' ','2019-01-03','2019-01-05','2019-01-07','2019-01-09','2019-01-11','2019-01-13'});
legend('\fontname{Times new roman}Simulation','\fontname{Times new roman}Observation','Location','Northeast','FontSize',14);
set(gca,'linewidth',0.7,'fontsize',14,'fontname','Times new roman')
ylabel('\fontname{Times new roman}Radiation (W/m^2)','FontSize',14,'Position', [-3, 700, 0]);
xlabel('\fontname{Times new roman}Datetime','FontSize',16);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%删除右上刻度线
box off     % 取消边框
ax3 = axes('Position', get(gca, 'Position'), 'XAxisLocation', 'top', 'YAxisLocation', 'right', 'Color', 'none', 'XColor', 'k', 'YColor', 'k');
set(ax3,'XTick', [],'YTick', []);   % 去掉xy轴刻度
hold off
set(0,'defaultfigurecolor','w');
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%删除右上刻度线
title('XingTai-Radiation','fontsize',14,'fontname','Times new roman');

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

返回顶部