matlab读取CMEMS海洋温度数据并调整图片的比例
matlab读取CMEMS海洋温度数据并调整图片的比例
数据的下载见上期:
链接到CMEMS数据下载{python}
本文还会给出另一个关键技巧:
通常设置图片比列直接可以通过
set(picture,'position',[10 20 3*300,2*300])
但在海图中此设置不起作用。
而需要通过调用函数设置:
daspect([0.8 1 1]) % 设置 X:Y:Z 比例为 2:1:1
直观感受不同比列的图片
图片
图片
图片
数据的读取:
clear;clc;close all;
%% step _ 01 read data and get ano data
ncdisp 'cmems_mod_glo_phy_my_0.083deg-climatology_P1M-m_1742636563411.nc'
file = 'cmems_mod_glo_phy_my_0.083deg-climatology_P1M-m_1742636563411.nc';
lon = double(ncread(file,'longitude'));
lat = double(ncread(file,'latitude'));
thetao = squeeze(ncread(file,'thetao'));
数据的画图
close all
figure('position',[10 3 650 350],'color','w');
set(gcf,'Position',[100,100,1200,800]);
m_proj('miller','lon',[-180 180],'lat',[-90 90 ]);
m_pcolor(lon,lat,thetao')
shading interp
colormap(jet)
colorbar;
hold on
[C,h]=m_contour(lon,lat,thetao',[0:10:30]);
set(h,'ShowText','on','linestyle','-','Color', 'r','LineWidth',1.5);%显示等值线 ,'TextList',mylabel
clabel(C,h,'fontsize',12,'color','k','LabelSpacing',4000) ;
% m_gshhs_f('patch',[0.7 0.7 0.7],'edgecolor','k','linewidth',1.2);
m_coast('patch',[0.7 0.7 0.7],'edgecolor','k','linewidth',1.2);
m_grid('linest','-.','xtick',8,'ytick',5,'tickdir','in','linewidth',2,'FontName','Times new roman','FontSize',16,'color','k','box','on','fontweight','bold')
title('Aspect ratio is default','FontName','Times new roman','FontSize',16,'color','k','fontweight','bold')
export_fig('read_cmems_ratio_original.jpg','-r300')
% 调整比例
title('Aspect ratio is 0.8:1','FontName','Times new roman','FontSize',16,'color','k','fontweight','bold')
比例的调整
daspect([0.8 1 1]) % 设置 X:Y:Z 比例为 2:1:1
图片的输出
export_fig('read_cmems_ratio_1.jpg','-r300')
全部的代码:
clear;clc;close all;
%% step _ 01 read data and get ano data
ncdisp 'cmems_mod_glo_phy_my_0.083deg-climatology_P1M-m_1742636563411.nc'
file = 'cmems_mod_glo_phy_my_0.083deg-climatology_P1M-m_1742636563411.nc';
lon = double(ncread(file,'longitude'));
lat = double(ncread(file,'latitude'));
thetao = squeeze(ncread(file,'thetao'));
close all
figure('position',[10 3 650 350],'color','w');
set(gcf,'Position',[100,100,1200,800]);
m_proj('miller','lon',[-180 180],'lat',[-90 90 ]);
m_pcolor(lon,lat,thetao')
shading interp
colormap(jet)
colorbar;
hold on
[C,h]=m_contour(lon,lat,thetao',[0:10:30]);
set(h,'ShowText','on','linestyle','-','Color', 'r','LineWidth',1.5);%显示等值线 ,'TextList',mylabel
clabel(C,h,'fontsize',12,'color','k','LabelSpacing',4000) ;
% m_gshhs_f('patch',[0.7 0.7 0.7],'edgecolor','k','linewidth',1.2);
m_coast('patch',[0.7 0.7 0.7],'edgecolor','k','linewidth',1.2);
m_grid('linest','-.','xtick',8,'ytick',5,'tickdir','in','linewidth',2,'FontName','Times new roman','FontSize',16,'color','k','box','on','fontweight','bold')
title('Aspect ratio is default','FontName','Times new roman','FontSize',16,'color','k','fontweight','bold')
export_fig('read_cmems_ratio_original.jpg','-r300')
% 调整比例
title('Aspect ratio is 0.8:1','FontName','Times new roman','FontSize',16,'color','k','fontweight','bold')
daspect([0.8 1 1]) % 设置 X:Y:Z 比例为 2:1:1
export_fig('read_cmems_ratio_1.jpg','-r300')
% 调整比例
% 调整比例
title('Aspect ratio is 0.5:1','FontName','Times new roman','FontSize',16,'color','k','fontweight','bold')
daspect([0.5 1 1]) % 设置 X:Y:Z 比例为 2:1:1
export_fig('read_cmems_ratio_2.jpg','-r300')
% 调整比例
title('Aspect ratio is 1:1','FontName','Times new roman','FontSize',16,'color','k','fontweight','bold')
% 调整比例
daspect([1 1 1]) % 设置 X:Y:Z 比例为 2:1:1
export_fig('read_cmems_ratio_3.jpg','-r300')
% 调整比例
title('Aspect ratio is 1:1.5','FontName','Times new roman','FontSize',16,'color','k','fontweight','bold')
% 调整比例
daspect([1 1.5 1]) % 设置 X:Y:Z 比例为 2:1:1
export_fig('read_cmems_ratio_4.jpg','-r300')
% 调整比例
title('Aspect ratio is 1:2','FontName','Times new roman','FontSize',16,'color','k','fontweight','bold')
% 调整比例
daspect([1 2 1]) % 设置 X:Y:Z 比例为 2:1:1
export_fig('read_cmems_ratio_5.jpg','-r300')