function results = space_time_plot(LT,sims,s,t)

%SPACE_TIME_PLOT yields a plot of the pvals from SPACE_TIME_PVALS.

%SPACE_TIME_PVALS computes space-time K-function for a given space-time pattern,
%and in addition, computes the (cluster) P-values for a set of random time 
%relabelings of that pattern. 

%Written by: TONY E. SMITH, 2/7/05

%Functions called: space_time_ct.m
%
% INPUTS:
%     (i)   LT   = location-time file [loc(i)=(Xi,Yi,Ti),i=1..n]
%     (ii)  sims = number of relabelings
%     (iii)    s = number of point values to use in space range.
%     (iv)     t = number of point values to use in time range.

% OUTPUTS: 1x4)-structure, results
%     (i)    results.cdf   = (s x t) matrix of CDF values for original pattern.
%     (ii)   results.pvals = (s x t) matrix of P-values.
%     (iii)  results.dist  = (s x 1) array of distance values.
%     (iv)   results.time  = (t x 1) array of time values.
%           [Here the max pairwise distance, Dmax, and time interval,
%            Tmax,are computed and (d0,t0) = (Dmax/2,Tmax/2)then 
%            defines the relevant ranges.]

%Run SPACE_TIME_PVALS

results = space_time_pvals(LT,sims,s,t);

%Compute space-time mesh

D = results.dist;

T = results.time;

PVals = results.pvals;

PVAL = min(.80,1 - PVals); %Easier to read as a plot

D = results.dist;

T = results.time;

PVals = results.pvals;

%SIG = max(.80,1 - PVals) ; %Easier to read as a plot

V = [.001,.002,.005,.01,.02,.05,.10];

[X,Y] = meshgrid(D,T);

[C,h] = contour(X,Y,PVals,V);

set(h,'LineWidth',2);

colormap hot

colorbar('vert');

xlabel('Distance','Fontsize',12, 'FontWeight', 'bold');

ylabel('Time','Fontsize',12, 'FontWeight', 'bold');

title('SPACE-TIME P-VALUES','Fontsize',12, 'FontWeight', 'bold');



%Type 'help graph3d' and look under 'Color maps" for further options

%use colormap([1 1 1]) to remove all colors



