clf
%nn=8;



if isempty(Tdata(nn).index_Background) || isempty(Tdata(nn).index_Testing)
title(['Original Dimension - ',Tdata(nn).field],'Interpreter','none')
text(0.14,0.75,'No events detected!!','FontSize',26,'Color',[0.9 0.10 0.05])
text(0.21,0.6,'Please select another','FontSize',20)
text(0.06,0.5,'backgound or/and testing period','FontSize',20)
else
    
    
Tdata(nn);
%if strcmp(Tdata(nn).Source,'Catalog')==1;
XB=Tdata(nn).origval_all(Tdata(nn).index_Background);
XT=Tdata(nn).origval_all(Tdata(nn).index_Testing);
%elseif strcmp(Tdata(nn).Source,'Production')==1;
%XB=Tdata(nn).origval(Tdata(nn).index_Background);
%XT=Tdata(nn).origval(Tdata(nn).index_Testing);
%end

st=range([XT;XB])/25;
a=(min([XT;XB]):st:max([XT;XB]));if isempty(a);a=[min(XT)/2 3*min(XT)/2];end;a10=0:0.1:1.0;  % control empty(a)
XL=[min([XT;XB]) max([XT;XB])];if range(XL)==0;XL=[min(XT)-0.1 min(XT)+0.1];end   

subplot(3,1,1)
histogram(XB,a,'FaceColor',[0.08 0.14 0.90]);hold on;xlim(XL);title(Tdata(nn).field,'Interpreter', 'none')
histogram(XT,a,'FaceColor',[0.87 0.90 0.99]);lgd1=legend('Background Sample','Testing Data','Location','northeast');
title(['Original Dimension - ',Tdata(nn).field],'Interpreter','none')
if strcmp(Tdata(nn).field,'Transformed_Time') | strcmp(Tdata(nn).field,'Transformed_Date');datetick('x',20,'keeplimits');end

subplot(3,1,2)
histogram(Tdata(nn).xBG,a10,'FaceColor',[0.08 0.14 0.90]);hold on;
histogram(Tdata(nn).xt,a10,'FaceColor',[0.87 0.90 0.99])
title('Equivalent Dimension')
subplot(3,1,3)
plot(Tdata(nn).xx,Tdata(nn).ambd,'o');xlim(XL)
title('adaptive kernel');
if strcmp(Tdata(nn).field,'Transformed_Time') | strcmp(Tdata(nn).field,'Transformed_Date');datetick('x',20,'keeplimits');end
end


