% :::::::::  create:  Ho - HA - TEST   with   Stem + Area -  Indexing ::::::::::::::.
% :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
clear all; close all; clf

fprintf(1, '\n')   
disp(['°°°°°°°°°°°°° S T A R T °°°°°°°°°°°° ' ,date, ' °°°°°°°°°°°°°°'])

mu = 0;
var = 10^2;                                % Varianz
N = 20;
x = linspace(-25,25);
y = N*exp(-(x-mu) .^2 / var);
n = length(x);
colormap(prism(6))
% ::::::::::::::::::::::::: selected Quantile - Elements :::::::::::::::::::
perc = [ 0.05  .25 .75 .95];
xx = sort(x);
ap = (length(x)*perc);                                                 
Quants = xx([ap])                                               % roughly the 5% til 95% entity 
disp('=====================================')
% :::::::::::::::::::::::::::::
k = 3;
Xstem = x(x <Quants(k));
Ystem = y(x <Quants(k));
% :::::::::::::::::
xMid = x((x >= Quants(k-1)) & (x <= Quants(k)));
yMid = y((x >= Quants(k-1)) & (x <= Quants(k)));
% ::::::::::::::::::::::::::::
P1 = [0.15,  0.25, 0.75,  0.7];                              % Position des Hauptplots
P2 = [0.15,  0.15, 0.75,  0.05];                            % Position der COLORBAR
P3 = [0.15,  0.12, 0.75,  0.005];                           % Position der t- / F- Tafel-Values
figure(1)
set(gcf, 'color', [0.85 0.85 0.75] )
ax1 = axes('Position',P1);               
    HP = plot(x,y,'r', 'Linewidth', 1.5);
    title('\bf 2-sided  t- F- Test  Distribution ', 'Fontsize', 14)
    hold on
    HS = stem(xMid, yMid);
    set(HS, 'Color', 'b' , 'Linewidth', 1);
    set(gca, 'XTick', [],'YTick', []);    
 % ::::::::::::::::::::::::::::: AREA - Quantile ::::::::::::::::::::
    xidx = x ((x<=Quants(k-1))  & (x >= Quants(k)));
    yidx = y ((x<=Quants(k-1))  & (x >= Quants(k)));
    area(xidx, yidx, 'Facecolor', 'y'); 
    set(gca,'XTickLabel',[],'XLim',[x(1) x(end)]);        
    set(gca, 'color', [0.85 0.85 0.75] )
% :::::::::::::::::::::::::::::::: Colorbar  with  PCOLOR :::::::::::::::::::::::::::::::::::
ax2 = axes('Position',P2);               
% M1 = colormap(hsv(2));
M2 = [cool(2); prism(6)];
colormap(M2)
cx = [ x(1),Quants(k-1), Quants(k), x(end) ];
Cx = [cx; cx];
Cy = [0 ; 1] * ones(size(cx));
cb = pcolor(Cx,Cy,Cx);
set(ax2,'YTick',[], 'XTick',[]);
% set(cb, 'Facecolor', 'c')
ht1 = text(mean(mean(Cx(:,1:2))),mean(mean(Cy(:,1:2))),'\bf HA');
ht2 = text(mean(mean(Cx(:,2:3))),mean(mean(Cy(:,2:3))),'\bf HO');
ht3 = text(mean(mean(Cx(:,3:4))),mean(mean(Cy(:,3:4))),'\bf HA');
set([ht1,ht2, ht3],'HorizontalAlignment','center','VerticalAlignment','middle');
% :::::::::::::::::::::::::::::::: Text-Box for  t - or  F- Tafel-Value ::::::::::::::
TexBo = {'\bf \uparrow Textbox'; 'F-Value'} ;
HT = text(Quants(k), -0.7, TexBo);
set(HT, 'color', 'b', 'Backgroundcolor', 'y', 'Fontsize', 12);

% ___________DATUM_________________________________
ax4 = axes('Position',[0.02,0.03,0.001,0.001],'Color','none','YColor','w');
printdate2 = ['printed on : ', datestr(now, 22), '.'];
printdate3 = {'uweko68', printdate2};
text(-0.2, -0.08, printdate3, 'units', 'normalized',   'fontangle', 'italic', 'fontsize', 8);
