Home > omviz > pslice.m

pslice

PURPOSE ^

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

SYNOPSIS ^

function 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 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 end
0022 u(ind)=max(u(ind),cax(1));
0023 u(ind)=min(u(ind),cax(2));
0024 [m,n]=size(x);
0025 if(min(m,n)>1),
0026   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));
0027   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));
0028   u(1,:)=[];
0029   u(:,1)=[];
0030 end
0031 if(exist('label')==1),
0032   clegend4(cax',label);pcolor(x,y,u);colormap('jet');...
0033 else
0034   clegend4(cax');pcolor(x,y,u);colormap('jet');...
0035 end
0036 shading('flat');caxis(cax);
0037 matlab_version = version;
0038 if ( matlab_version(1) == '5' )
0039         set ( gca, 'DataAspectRatio', [1 1 1] );
0040 else
0041         set(gca,'aspectratio',[NaN 1])
0042 end

Generated on Thu 01-Dec-2005 08:50:35 by m2html © 2003