function PVal = k12_shift_plot(L1,L2,xmin,xmax,ymin,ymax,sims,D,s)

%K12_SHIFT compares two point populations L1,L2 in a (len x hgt) box by simulating 
%many random shifts of L2 (with L1 fixed) and computing K12-values for a range D of
%distance values. P-values are then computed, reflect significant attraction and/or 
%repulsion between these patterns.

%NOTE 1: By convention, low P-Values here correspond to significant ATTRACTION between 
%        patterns.
%NOTE 2: Ties are treated neutrally, adding .5 rather 1 to rankings.

%Written by: TONY E. SMITH, 12/2/01

% INPUTS:
%     (i)   L1   = locations of pop1
%     (ii)  L2   = locations of pop2
%     (iii) xmin,xmax,ymin,ymax = box limits
%     (iv)  sims = number of random shifts
%     (v)   D    = vector of distance values at which to measure k12-values
%     (vi)   s    = optional specification of random seed. Default seed = 23311.
%                  s = 1 if random seed is to be used.
%                  s = 5_digit positive integer to be used as seed 


% OUTPUTS:  PVal = Vector of P-Values at each distance in D .

%Functions called: k12_shift

% SCREEN OUTPUT:  A plot of P-Values against distances in D.


% Compute Initial Seed

if nargin == 8
   
   s = 23311; %forest seed (default)   
    
   %s =      ; %myrtles seed
   
elseif s == 1
   
   s = round(100000*rand(1))
   
else
   
   s = s;
   
end



%Call K12_SHIFT

PVal = k12_shift(L1,L2,xmin,xmax,ymin,ymax,sims,D,s);


%SCREEN OUTPUT: Plot of PVal against D

plot(D,PVal,'k.','MarkerSize',20);

hold on;

plot(D,PVal,'k-','LineWidth',2);

hold on;

SIG = .05*ones(length(D),1);

plot(D,SIG,'r--');

plot(D,1-SIG,'r--');

xlabel('Radius','Fontsize',12, 'FontWeight', 'bold');

ylabel('attraction                   P-Value                    repulsion',...
   'Fontsize',12, 'FontWeight', 'bold');


