function c=mapback(c,xdata,ydata,scatRect,displayAxis,plotColor)
% This function takes the data points from the scatter plot and plots them on the original figure
% Kevin Baggett
% 31 Jul 2001 11:31:42 
% Inputs: imagedata - image of the subplot
%         xdata,ydata - data associated with the scatter plot
%         scatRect - the rectangle from the scatter plot
%         displayAxis - axis on which to make plot
%         plotColor - 3-element matrix of color to be plotted for selected data
% Outputs: none


[nrow,ncol]=size(xdata);
x=reshape(xdata,nrow*ncol,1);
y=reshape(ydata,nrow*ncol,1);
indx=find((x > scatRect(1) & x < scatRect(1)+scatRect(3)) & ...
       (y > scatRect(2) & y < scatRect(2)+scatRect(4)));

cred=reshape(c(:,:,1),nrow*ncol,1);
cred(indx)=plotColor(1);
c(:,:,1)=reshape(cred,nrow,ncol);
cgreen=reshape(c(:,:,2),nrow*ncol,1);
cgreen(indx)=plotColor(2);
c(:,:,2)=reshape(cgreen,nrow,ncol);
cblue=reshape(c(:,:,3),nrow*ncol,1);
cblue(indx)=plotColor(3);
c(:,:,3)=reshape(cblue,nrow,ncol);

axes(displayAxis);
cax=caxis;
cla;
imagesc(c);
caxis(cax);
colorbar;
set(gca,'XTick',[]);
set(gca,'YTick',[]);
