%function h = sedimentatlas_plot_diameter(D,fname)
%sedimentatlas_plot_diameter   plots graph of diameter
% sedimentatlas_plot_diameter(d,phi,cumphi,fname)
%
%See also: 

d = D.diameter;
basename = 'A';

h = gcf;clf

    dtext = strtrim(cellstr(num2str((d))));
    dtext{  1} = '4.0';
    dtext{  2} = '2.8';
    dtext{  3} = '2.0';
    dtext{  4} = '1.4';
    dtext{  5} = '1.0';
    dtext{end} = '0.7';
%% plot set-up    
AX = subplot_meshgrid(1,2,[.04 .02],[.01 .05 .05]);
    
    axes(AX(1))
   %semilogx(d,D.phi,'linewidth',.01,'color',[.5 .5 .5]);
    hold on 
    xlim([0.5 5e3])
    ylim([0 60])
    text(0,.5,'fraction per diameter class [%]','units','normalized','rotation',90,'horiz','cen','vert','top')
    grid on
    hold on
    plot(d, 0.*d,'k^')
    set(gca,'xticklabel',{})
    text(d(7:end)*.9, 0.*d(7:end)-2,dtext(7:end),'verti','top','fontsize',8)
    text(d(1:6  ), 0.*d(1:6  )-2,dtext(1:6  ),'verti','top','fontsize',8)    
    text(d(6),-4,'\mum','verti','top','fontsize',8)    
    text(d(1),-4,'mm','verti','top','fontsize',8)
    h.plot1 = semilogx(d,D.phi(j,:),'k','linewidth',4); %(j,:)
    h.text1 = text(.7,55,['(',num2str(D.lon(j)),'\circE,',num2str(D.lat(j)),'\circN)'])

    axes(AX(2))
    semilogx(d,D.cumphi,'linewidth',.01,'color',[.5 .5 .5]);
    hold on 
    h.plot2 = semilogx(d,D.cumphi(j,:),'k','linewidth',4);
    xlim([0.5 5e3])
    ylim([0 100])
    text(1200,-3,'diameter [mm]','vert','top');
    text(0,.5,'cumulative fraction per diameter class [%]','units','normalized','rotation',90,'horiz','cen','vert','top')
    grid on

    %% replot data for one profile
    for j=1:length(D.lon);
        set(h.plot1,'ydata',D.phi(j,:));
        set(h.text1,'String',['ID = ',num2str(D.ID(j)),': (',num2str(D.lon(j)),'\circE,',num2str(D.lat(j)),'\circN)']);
        set(h.plot2,'ydata',D.cumphi(j,:));
        print2screensizeoverwrite([num2str(D.ID(j))]);
    end    
