%
%   loglog_plot_all_alt.m  ver 1.7  by Tom Irvine
%
function[fig_num]=loglog_plot_all_alt(fig_num,t_string,ppp,leg,xlab,ylab)
%

sz=size(ppp);

f=ppp(:,1);
amp=ppp(:,2:sz(2));

sz=size(amp);

%

hp=figure(fig_num);
%
hold on;


for i=1:sz(2)
    
    if(i<=3)
        try
            if(i==1)
                plot(f,amp(:,i),'b','DisplayName',char(leg(i)),'LineWidth',1);
            end
            if(i==2)
                plot(f,amp(:,i),'r','DisplayName',char(leg(i)),'LineWidth',1);
            end
            if(i==3)
                plot(f,amp(:,i),'k','DisplayName',char(leg(i)),'LineWidth',1);
            end
            if(i>=4)
                plot(f,amp(:,i),'DisplayName',char(leg(i)),'LineWidth',1);
            end         
        catch
            if(i==1)
                plot(f,amp(:,i),'b','DisplayName',leg{i},'LineWidth',1);
            end
            if(i==2)
                plot(f,amp(:,i),'r','DisplayName',leg{i},'LineWidth',1);
            end
            if(i==3)
                plot(f,amp(:,i),'k','DisplayName',leg{i},'LineWidth',1);
            end
            if(i>=4)
                plot(f,amp(:,i),'DisplayName',leg{i},'LineWidth',1);
            end    
        end
        if(i==3)
            L = legend;
            legend show;
            L.AutoUpdate = 'off'; 
        end    
    else
        
        try
            plot(f,amp(:,i));
        catch
            try
                plot(f,amp(:,i));            
            catch
            end
        end
    end
end



set(gca,'MinorGridLineStyle',':','GridLineStyle',':','XScale','log','YScale','log')
grid on;
  
title(t_string)
xlabel(xlab);
ylabel(ylab);

fmin=min(f);
fmax=max(f);


if(fmin>20)
    fmin=20;
end

%
[xtt,xTT,iflag]=xtick_label(fmin,fmax);

if(iflag==1)
    set(gca,'xtick',xtt);
    set(gca,'XTickLabel',xTT);
    fmin=min(xtt);
    fmax=max(xtt);
end

md=5;
upper=max(max(ppp(:,2:end)));
lower=min(min(ppp(:,2:end)));
[ymax,ymin]=ymax_ymin_md(upper,lower,md);


try
    ylim([ymin,ymax]);
catch
end


%
grid on;
set(gca, 'xminorgrid', 'on', 'yminorgrid', 'on')

xlim([fmin,fmax]);

fig_num=fig_num+1;

legend show;
    
legend('location','northeast')
set(hp, 'Position', [0 0 900 550]);
set(gca,'Fontsize',10.5);
    

hold off;

