Matlab——m_map指南(3)——实例m_map 实例
1、
clear all
m_proj('ortho','lat', 48,'long',-123');%投影⽅式,范围
m_coast('patch','r');%红⾊填充
m_grid('linest','-','xticklabels',[],'yticklabels',[]);%标注为空
patch(.55*[-1 1 1 -1],.25*[-1 -1 1 1]-.55,'w');%四个点,⽩⾊填充
text(0,-.55,'M\_Map','fontsize',25,'color','b',...
'vertical','middle','horizontal','center');%填充内容,属性要求,垂直⽔平居中,斜杠转义符
set(gcf,'units','inches','position',[2 2 3 3]);%设置图⽚⼤⼩
set(gcf,'paperposition',[3 16 6 6]);%[left bottom width height].
2.
clear all
m_proj('lambert','long',[-160 -40],'lat',[30 80]);
m_coast('patch',[1 .85 .7]);%填充海岸线
m_elev('contourf',[500:500:6000]);%海深等⾼线
m_grid('box','fancy','tickdir','in');
colormap(flipud(copper));%翻转三原⾊的顺序排列,重新画图
3、
m_proj('stereographic','lat',90,'long',30,'radius',25);
m_elev('contour',[-3500:1000:-500],'edgecolor','b');
m_grid('xtick',12,'tickdir','out','ytick',[70 80],'linest','-');
m_coast('patch',[.7 .7 .7],'edgecolor','r');
4、
4.1默认的加载形式
clear all
Slongs=[-100 0;-75 25;-5 45; 25 145;45 100;145 295;100 290];
Slats= [  8 80;-80  8; 8 80;-80  8; 8  80;-80  0;  0  80];
for l=1:7,
m_proj('sinusoidal','long',Slongs(l,:),'lat',Slats(l,:));%分区块的载⼊地图
m_grid;
m_coast;
end;
xlabel('Interrupted Sinusoidal Projection of World Oceans');
% In order to see all the maps we must undo the axis limits set by m_grid calls:
set(gca,'xlimmode','auto','ylimmode','auto');%⾃动加载所有数据
4.2
clear all
subplot(211);
Slongs=[-100 0;-75 25;-5 45; 25 145;45 100;145 295;100 290];
Slats= [  8 80;-80  8; 8 80;-80  8; 8  80;-80  0;  0  80];
for l=1:7,
m_proj('sinusoidal','long',Slongs(l,:),'lat',Slats(l,:));
m_grid('fontsize',6,'xticklabels',[],'xtick',[-180:30:360],...%字体尺⼨,隐藏坐标,坐标等距离排列        'ytick',[-80:20:80],'yticklabels',[],'linest','-','color',[.9 .9 .9]);%线条形式实线,颜⾊
m_coast('patch','g');%填充绿⾊
end;
xlabel('Interrupted Sinusoidal Projection of World Oceans');
% In order to see all the maps we must undo the axis limits set by m_grid calls:
set(gca,'xlimmode','auto','ylimmode','auto');
subplot(212);
Slongs=[-100 43;-75 20; 20 145;43 100;145 295;100 295];
Slats= [  0  90;-90  0;-90  0; 0  90;-90  0;  0  90];%⽐上⾯范围重叠更多
for l=1:6,
m_proj('mollweide','long',Slongs(l,:),'lat',Slats(l,:));
m_grid('fontsize',6,'xticklabels',[],'xtick',[-180:30:360],...
'ytick',[-80:20:80],'yticklabels',[],'linest','-','color','k');
m_coast('patch',[.6 .6 .6]);
end;
xlabel('Interrupted Mollweide Projection of World Oceans');
set(gca,'xlimmode','auto','ylimmode','auto');%⾃动加载所有数据范围
5、
clear all
% Nice looking data
[lon,lat]=meshgrid([-136:2:-114],[36:2:54]);
u=sin(lat/6);%?
v=sin(lon/6);
m_proj('oblique','lat',[56 30],'lon',[-132 -120],'aspect',.8);%注意纬度顺序,⾼纬到低纬,'aspect'长宽⽐subplot(121);
m_coast('patch',[.9 .9 .9],'edgecolor','none');
m_grid('tickdir','out','yaxislocation','right',...%边缘经纬线在外,纬度在右,经度在顶
'xaxislocation','top','xlabeldir','end','ticklen',.05);%边缘经纬度宽度
hold on;%图层合并
m_quiver(lon,lat,u,v);%经度,纬度,向东,向北的速度分量,转化为⽮量箭头
xlabel('Simulated surface winds');
subplot(122);
m_coast('patch',[.9 .9 .9],'edgecolor','none');
m_grid('tickdir','in','yticklabels',[],...
'xticklabels',[],'linestyle','none','ticklen',.02);%经纬线去除
hold on;
[cs,h]=m_contour(lon,lat,sqrt(u.*u+v.*v));%画出轮廓
matlab等高线间隔
clabel(cs,h,'fontsize',10,'Color','red','FontWeight','bold');%标注轮廓,字体,字体⼤⼩,颜⾊
xlabel('Simulated something else');
6、
clear all
% Plot a circular orbit
lon=[-180:180];
lat=atan(tan(60*pi/180)*cos((lon-30)*pi/180))*180/pi;
m_proj('miller','lat',80);%查询,纬度(-80 80),经度(-180 180)
m_coast('color',[0 .6 0]);
m_line(lon,lat,'linewi',2,'color','r');%线宽,2;颜⾊
m_grid('linestyle','none','box','fancy','tickdir','in');%没有⽹格,边框相间,
%m_line(lon,lat,'linewi',2,'color','r','linestyle',':');控制线条格式,点画线还是直线
7、
clear all
m_proj('lambert','lon',[-10 20],'lat',[33 48]);%范围设置与投影有关系
m_tbase('contourf');%画5-min数据库轮廓
m_grid('linestyle','none','tickdir','out','linewidth',3);
没有安装terrainbase,所以轮廓很简陋,这个坑⽤到的时候再填
8、不同分辨率情况下画的图
clear all
% Example showing the default coastline and all of the different resolutions
% of GSHHS coastlines as we zoom in on a section of Prince Edward Island.
clf
axes('position',[0.35 0.6 .37 .37]);%[left  bottom  width  height]
m_proj('albers equal-area','lat',[40 60],'long',[-90 -50],'rect','on');%⽅形,扇形
m_coast('patch',[0 1 0]);%填充
m_grid('linest','none','linewidth',2,'tickdir','out','xaxisloc','top','yaxisloc','right');
m_text(-69,41,'Standard coastline','color','r','fontweight','bold');%经纬度,内容,格式axes('position',[.09 .5 .37 .37]);
m_proj('albers equal-area','lat',[40 54],'long',[-80 -55],'rect','on');
m_gshhs_c('patch',[.2 .8 .2]);
m_grid('linest','none','linewidth',2,'tickdir','out','xaxisloc','top');
m_text(-80,52.5,'GSHHS\_C (crude)','color','m','fontweight','bold','fontsize',14);
axes('position',[.13 .2 .37 .37]);
m_proj('albers equal-area','lat',[43 48],'long',[-67 -59],'rect','on');
m_gshhs_l('patch',[.4 .6 .4]);
m_grid('linest','none','linewidth',2,'tickdir','out');
m_text(-66.5,43.5,'GSHHS\_L (low)','color','m','fontweight','bold','fontsize',14);
axes('position',[.35 .05 .37 .37]);
m_proj('albers equal-area','lat',[45.8 47.2],'long',[-64.5 -62],'rect','on');
m_gshhs_i('patch',[.5 .6 .5]);
m_grid('linest','none','linewidth',2,'tickdir','out','yaxisloc','right');
m_text(-64.4,45.9,'GSHHS\_I (intermediate)','color','m','fontweight','bold','fontsize',14); axes('position',[.55 .23 .37 .37]);