No BSD License  

2D Plotting with Mapping Toolbox

by

 

10 May 2005 (Updated )

This function plots a 2D Surface (shading interp, no white edges).

splot1(map,maplegend)
function splot1(map,maplegend)

%input: map [nxm] & maplegend
%output: surfaceplot with shading interp
% (c) 10.05.2005 Felix Mueller, University Bonn

Titel    = input('Enter title: ','s');
Cbar     = input('Enter unit Colorbar: ','s');
Filename = input('Enter file name: ','s');
fontsize=10;
[n m]=size(map);

%Figure setup

figure('Color','white');
[latgrat,longrat] = meshgrat(map,maplegend,[n m]);
la1=round(min(min(latgrat)));la2=round(max(max(latgrat)));
lo1=round(min(min(longrat)));lo2=round(max(max(longrat)));
latlim = [la1 la2];longlim = [lo1 lo2];
axesm('mapprojection','lambert','maplatlimit',latlim,'maplonlimit',longlim,...
   'grid','on','mlinelocation',1,'mlinevisible','on','plinelocation',1,...
    'plinevisible','on','labelrotation','on','meridianlabel','on',...
    'mlabellocation',1,'parallellabel','on','plabellocation',1);
mlabel(latlim(1));
handle_surf = surfm(latgrat,longrat,map);
shading interp
framem on
zdatam(handlem('frame'), max(map(:)))

%Colorbar

hca=colorbar;
set(hca,'Fontsize',fontsize);  
set(get(hca,'Title'),'String',Cbar,'Fontsize',fontsize);
set(hca,'OuterPosition',[0.916 0.013 0.099 0.944]); %optional 
set(hca,'Position',[0.92 0.117 0.039 0.77]);        %optional 

%Title

h=title(Titel,'Fontsize',14);
hidem(gca)
showm(h)
set(h,'Position',[0 0.898 200]);                    %optional

%White edge compensation

xd = get(handle_surf,'xdata');
xd(:,1) = xd(:,2)-(xd(:,3)-xd(:,2));
set(handle_surf,'xdata',xd);
yd = get(handle_surf,'ydata');
yd(:,1) = yd(:,2)-(yd(:,3)-yd(:,2));
set(handle_surf,'ydata',yd);
zdatam(handlem('frame'), max(map(:)))
axis normal

% Optional save of the figure in png-format

if isempty(Filename)==false
    cd figures
    eval(['print -zbuffer -dpng -r300 ' Filename '.png'])
    cd ..
end

Contact us