function DrawAnalysis(titletext,type,value,N)

%DrawAnalysis   Draw error bars with the results of the analysis
%
% DrawAnalysis(titletext,type,value,N)
% 
% titleext:Title of the figure
% type: 0/1/2 --> what to draw (0 --> mean concentration, 1 & 2 ratios)
% value(i,k) number of the ith experiment for the N(i) sample size
% N(i): sample size used to generate value
%

% APRENDIZAJE AUTOMÁTICO (G. Pajares y J. M. de la Cruz, Eds.)
% Editorial: RA-MA
% Capítulo 7 y 8: Monte Carlo I y II
% Autores: Eva Besada-Portas, Sergey M. Plis


switch(type)
    case 0 %Red, round poits, basic case
    errorbar(log10(N),mean(value,1),sqrt(diag(cov(value,1))),'or','MarkerFaceColor','r')
    case 1 %Green, circle, another case
    errorbar(log10(N),mean(value,1),sqrt(diag(cov(value,1))),'og','MarkerFaceColor','g')    
    case 2 %Blue square, another case
    errorbar(log10(N),mean(value,1),sqrt(diag(cov(value,1))),'sb','MarkerFaceColor','b')
end

hold on;

if type==0 %We draw the mean val
    MainExact;
    plot(log10([100,1000000]),[I,I],':b','LineWidth',2);
end

%Change the X-axis information
xlim([1,7]);
aa=[[1:9]*100,[1:9]*1000,[1:9]*10000,[1:9]*100000,1000000];
set(gca,'XTick',log10(aa))
text=cell(length(aa),1);
text{1}=2;
text{10}=3;
text{19}=4;
text{28}=5;
text{37}=6;
set(gca,'XTickLabel',text);
xlabel('N=10^{#} Muestras','FontSize',12);

if type==0 %yaxis is the concentration
    ylabel('Concentracion (%)','FontSize',12);
else       %yaxis is a ratio
    ylabel('Ratio','FontSize',12);
end

if type==0 %the estimated integral, and the real value
    h=legend('I_N','I');
    set(h,'FontSize',12);
elseif type==2 %they are different sampling functions
    h=legend('q(C) uniforme','q(C) gausiano');
    set(h,'FontSize',12);
end


if type==0   %We limit the values, by default to +-1 the real meanval
    ylim([46,48]);
end
title(titletext,'FontSize',12);