Home > hiswa > pslice.m

pslice

PURPOSE ^

PSLICE Like Pcolor, but centered on grid cells, and includes a legend.

SYNOPSIS ^

function h=pslice(x,y,u,cax,label)

DESCRIPTION ^

 PSLICE  Like Pcolor, but centered on grid cells, and includes a legend.  
  USAGE: pslice(x,y,u,[cax],[label])
 x is array of x points
 y is array of y points 
 u is array of data
 cax is range of data to map  (autoscales if not supplied)

 EXAMPLE:  pslice(x,y,temp,[10 22],'Temperature')  
                Plots the variable temp from 10 to 22 deg, and labels the
                colorbar legend as "Temperature (C)"

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function h=pslice(x,y,u,cax,label)
0002 % PSLICE  Like Pcolor, but centered on grid cells, and includes a legend.
0003 %  USAGE: pslice(x,y,u,[cax],[label])
0004 % x is array of x points
0005 % y is array of y points
0006 % u is array of data
0007 % cax is range of data to map  (autoscales if not supplied)
0008 %
0009 % EXAMPLE:  pslice(x,y,temp,[10 22],'Temperature')
0010 %                Plots the variable temp from 10 to 22 deg, and labels the
0011 %                colorbar legend as "Temperature (C)"
0012 %
0013 
0014 % Rich Signell
0015 % rsignell@usgs.gov
0016 
0017 ind=find(~isnan(u));
0018 if(nargin<4),
0019  cax(1)=min(u(ind));
0020  cax(2)=max(u(ind));
0021  if(cax(2)==cax(1)),cax(1)=cax(1)-.001*cax(1);cax(2)=cax(2)+.001*cax2;end;
0022 else
0023  if(isnan(cax(1))),cax(1)=min(u(ind));end;
0024  if(isnan(cax(2))),cax(2)=max(u(ind));end;
0025 end
0026 u(ind)=max(u(ind),cax(1));
0027 u(ind)=min(u(ind),cax(2));
0028 [m,n]=size(x);
0029 if(min(m,n)>1),
0030   x=.25*(x(1:m-1,1:n-1)+x(2:m,1:n-1)+x(1:m-1,2:n)+x(2:m,2:n));
0031   y=.25*(y(1:m-1,1:n-1)+y(2:m,1:n-1)+y(1:m-1,2:n)+y(2:m,2:n));
0032   u(1,:)=[];
0033   u(:,1)=[];
0034 end
0035 if(exist('label')==1),
0036   clegend4(cax',label);h=pcolor(x,y,u);colormap('jet');...
0037   shading('flat');caxis(cax);set(gca,'aspectratio',[NaN 1])
0038 else
0039   clegend4(cax');h=pcolor(x,y,u);colormap('jet');...
0040   shading('flat');caxis(cax);set(gca,'aspectratio',[NaN 1])
0041 end

Generated on Wed 30-Nov-2005 15:36:39 by m2html © 2003