function h=plot_cfill(x,y,sym,col,ptsize,linestyle,lwidth,iilog,dmin,dmax,cmap);
% Call  h=plot_cfill(x,y,sym,col,ptsize,linestyle,lwidth,iilog,dmin,dmax,cmap);
% x,y = plot variables;
% sym='o' or 's' for circles or squares, diamonds, etc;
% col = 'r' for color;
% ptsize = point size for markers;
% linestyle = 'none' or '-', for example.
% lwidth = line width (>0);
% iilog: 0=normal plot, 1=semilogx, 2=semilogy, 3=loglog;
% For shade plots:	set col=the values corresponding to (x,y) to be shaded
%					set dmin,dmax=min,max value in col to plot
%					set cmap=color map to use (do not put in quotes);
if nargin<3, sym='o'; end
if nargin<4, col='r'; end
if nargin<5, ptsize=5; end
if nargin<6, linestyle='none'; end
if nargin<7, lwidth=1; end
if nargin<8, iilog=0; end
if isempty(sym), sym='o'; end
if isempty(col), col='r'; end
if isempty(ptsize), ptsize=5; end
if isempty(linestyle), linestyle='none'; end
if isempty(lwidth), lwidth=1; end
if isempty(iilog), iilog=0; end
% Line widths cannot be zero:
if lwidth==0, lwidth=.25; end
%
iishade=0;
dimc=size(col); dimx=size(x);
if length(dimc)==length(dimx) & (max(dimc)>1 | ~ischar(col)),
	if all(dimc==dimx), iishade=1; end
end
if iishade==0,
	if iilog==0,
		h=plot(x,y,'Marker',sym,'MarkerSize',ptsize,'MarkerFaceColor',col, ...
	   	'MarkerEdgeColor','none','Linestyle',linestyle,'LineWidth',lwidth, ...
		'Color',col);
	elseif iilog==1,
		h=semilogx(x,y,'Marker',sym,'MarkerSize',ptsize,'MarkerFaceColor',col, ...
	   	'MarkerEdgeColor','none','Linestyle',linestyle,'LineWidth',lwidth, ...
		'Color',col);
	elseif iilog==2,
		h=semilogy(x,y,'Marker',sym,'MarkerSize',ptsize,'MarkerFaceColor',col, ...
		   	'MarkerEdgeColor','none','Linestyle',linestyle,'LineWidth',lwidth, ...
			'Color',col);
	elseif iilog==3,
		h=loglog(x,y,'Marker',sym,'MarkerSize',ptsize,'MarkerFaceColor',col, ...
   		'MarkerEdgeColor','none','Linestyle',linestyle,'LineWidth',lwidth, ...
		'Color',col);
	end
else
	if nargin<11, 
		error(['For shaded symbol plots, must have 11 input arguments; ', ...
			'type help plot_cfill']);
	end
%
	if size(cmap,1) ~= 64, error('Color map cmap must have 64 rows!'); end
%
	iinum=find(col>=dmin);
	mmap=min(64,round(63*(col(iinum) - dmin)./(dmax-dmin) + 1));
%%	max(mmap),min(mmap),size(cmap),
	map=cmap(mmap,:);
	hold on; ndot=length(iinum); 
	if strcmp(linestyle,'none'), h=zeros(ndot,1); else, h=zeros(ndot+1,1); end
	if iilog==0,
		for jj=1:ndot,
			j=iinum(jj);
			h(jj)=plot(x(j),y(j),'Marker',sym,'MarkerSize',ptsize,'MarkerFaceColor',map(jj,:), ...
	   		'MarkerEdgeColor','none','Linestyle',linestyle,'LineWidth',lwidth, ...
			'Color',map(jj,:)); hold on;
		end
		if ~strcmp(linestyle,'none'),
			h(ndot+1)=plot(x(iinum),y(iinum),'Linestyle',linestyle,'Color','k');
		end
	elseif iilog==1,
		for jj=1:ndot,
			j=iinum(jj);
			h(jj)=semilogx(x(j),y(j),'Marker',sym,'MarkerSize',ptsize,'MarkerFaceColor',map(jj,:), ...
	   		'MarkerEdgeColor','none','Linestyle',linestyle,'LineWidth',lwidth, ...
			'Color',map(jj,:)); hold on;
		end
	elseif iilog==2,
		for jj=1:ndot,
			j=iinum(jj);
			h(jj)=semilogy(x(j),y(j),'Marker',sym,'MarkerSize',ptsize,'MarkerFaceColor',map(jj,:), ...
	   		'MarkerEdgeColor','none','Linestyle',linestyle,'LineWidth',lwidth, ...
			'Color',map(jj,:)); hold on;
		end
	elseif iilog==3,
		for jj=1:ndot,
			j=iinum(jj);
			h(jj)=loglog(x(j),y(j),'Marker',sym,'MarkerSize',ptsize,'MarkerFaceColor',map(jj,:), ...
	   		'MarkerEdgeColor','none','Linestyle',linestyle,'LineWidth',lwidth, ...
			'Color',map(jj,:)); hold on;
		end
	end
end	
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
