最近在使用M_Map工具包画图时,遇到了一个问题。我用m_pcolor在地图上画填充图,然后用m_scatter画出卫星轨迹上的散点数据。由于两种数据是不同类型的,单位也不同,需要分别设置两种数据的color scale。采用传统的对axes进行操作发现效果不好。最后把两个colorbar都取消掉,同时在画第一幅图之后设置m_grid则效果比较正常。代码如下:
figure;
ax1 = axes;
m_proj('UTM',...
'long',Options.Region(1:2),...
'lat',[Options.Region(3) Options.Region(4)]);
m_pcolor(minlon:dlon:maxlon,maxlat:-dlat:minlat,dVTEC);
shading interp;
m_coast('color','k');
m_grid('linestyle','none',...
'tickdir','out',...
'gridcolor',[0.6 .6 0.6],...
'linewidth',0.2,...
'ytick',Options.Region(4):-10:Options.Region(3),...
'xtick',Options.Region(1):20:Options.Region(2));
ax2=axes;
m_scatter(LonSelect,LatSelect,20,NeSelect);
caxis(ax1,[color_min,color_max]);
caxis(ax2,[0,1.2]);
%Link them together
linkaxes([ax1,ax2])
%%Hide the top axes
ax2.Visible = 'off';
ax2.XTick = [];
ax2.YTick = [];
%%Give each one its own colormap
colormap(ax1,'jet');
colormap(ax2,'jet');
set(gcf,'Units','centimeters','position',[10.8656 6.4735 9.8778 5.2917]);