function res = space_time_plot_output(results)

%SPACE_TIME_PLOT_OUTPUT takes the results of SPACE_TIME_PVALS as an input and uses 
%these to plot PVals.

%Written by: TONY E. SMITH, 2/7/05

%Functions called: space_time_pvals.m
%
% INPUTS: results from SPACE_TIME_PLOT

%Compute space-time mesh

D = results.dist;

T = results.time;

PVals = results.pvals;
% 
% PV = min(.80, PVals);
% 
% SIG = max(.80,1 - PVals) ; %Easier to read as a plot


%surf(D,T,SIG) ; 

%V = [.11,.13,.15,.20,.30,.40,.50,.60]
%V = [.02 .05 .10 .15 .20];
V = [.001,.002,.005,.01,.02,.05,.10];

[X,Y] = meshgrid(D,T);

%[C,h] = contour(X,Y,PVals,V);
[C,h] = contour(X,Y,PVals,V);

res.X = X;
res.Y = Y;
res.PVals = PVals;

set(h,'LineWidth',2);

%Define Hot Colormap 

Hot_Map = [0.50196            0            0
          0.53309            0            0
          0.56422            0            0
          0.59534            0            0
          0.62647            0            0
           0.6576            0            0
          0.68873            0            0
          0.71985            0            0
          0.75098            0            0
          0.78211            0            0
          0.81324            0            0
          0.84436            0            0
          0.87549            0            0
          0.90662            0            0
          0.93775            0            0
          0.96887            0            0
                1            0            0
                1     0.035714            0
                1     0.071429            0
                1      0.10714            0
                1      0.14286            0
                1      0.17857            0
                1      0.21429            0
                1         0.25            0
                1      0.28571            0
                1      0.32143            0
                1      0.35714            0
                1      0.39286            0
                1      0.42857            0
                1      0.46429            0
                1          0.5            0
                1      0.53571            0
                1      0.57143            0
                1      0.60714            0
                1      0.64286            0
                1      0.67857            0
                1      0.71429            0
                1         0.75            0
                1      0.78571            0
                1      0.82143            0
                1      0.85714            0
                1      0.89286            0
                1      0.92857            0
                1      0.96429            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0
                1            1            0];
        
set(gcf,'Colormap',Hot_Map); % Uses the Colormap 'Hot_Map' just defined.

caxis([.001, .02]); % Sets Color data min and max in Colormap editor

% Other Figure Information

colorbar('vert');

xlabel('Distance','Fontsize',12, 'FontWeight', 'bold');

ylabel('Time','Fontsize',12, 'FontWeight', 'bold');

title('SPACE-TIME P-VALUES','Fontsize',12, 'FontWeight', 'bold');

% pause;
% 
% clf;

% A Smoothing Procedure (SEEMS LESS STABLE)

% del = (max(T) - min(T))/50; 
% 
% T1 = [min(T):del:max(T)];
% 
% del = (max(D) - min(D))/50; 
% 
% D1 = [min(D):del:max(D)];
% 
% [X1,Y1] = meshgrid(D1,T1);
% 
% Z1 = interp2(X,Y,PVals,X1,Y1,'spline');
% 
% V = [.001,.002,.005,.01,.02,.05,.10];
% 
% [C,h] = contour(X1,Y1,Z1,V);
% 
% set(h,'LineWidth',2);
% 
% %colormap cool
% 
% colormap autumn
% 
% colorbar('vert');
% 
% xlabel('Distance','Fontsize',12, 'FontWeight', 'bold');
% 
% ylabel('Time','Fontsize',12, 'FontWeight', 'bold');
% 
% title('SPACE-TIME P-VALUES','Fontsize',12, 'FontWeight', 'bold')
% 


