function Display_Characteristicleaf_heights_in2D
%Used for Rolland-Lagan, Remmler and Girard-Bock (2014) paper to make supplemental figure of characteristic leaf surface in 2D colour coded for height of leaf heights in 2D.
%Next program to run: Display_local_curvature_data

close all;
days=7:19; 
%input('Enter DAS numbers contained in this data set ');

Path1=uigetdir(cd,'Select Reference data folder');
load([Path1 '\meanoutlines_DAS7-19.mat']);
Pathname=uigetdir(cd,'Select main project folder in  which all shape results and figures are stored');%AG July 2013: for saving mean leaf data
load([Pathname '\Local curvature data and figures\Characteristicleaves_localcurvaturedata.mat']);

%  load('C:\Users\Administrator\Dropbox\Lauren_shapepaper\SEP29_2013_GoodDataforMS\TESTMEANLEAF_SEP27_noextrap_borderclassok_V9\Meanleaves_Curvdatafromv9meanleafnoextrap.mat');
%  load('C:\Users\Administrator\Dropbox\Lauren_shapepaper\SEP29_2013_GoodDataforMS\meanoutlines3D_DAS7-19.mat');
PathName2=[Pathname '\3D surface and figures'];

 for ii=days(1):days(end)
     avx{ii}=cat(1,avx{ii},avx{ii}(1));
     avy{ii}=cat(1,avy{ii},avy{ii}(1));
 end
% %----- To register the min and max values for that period: ----------------------------------------------------
%DAS07 to DAS19:
for ii=days(1):days(end)
    ZIg_minimum(ii)=min(min(ZIg_all{ii}));
    ZIg_maximum(ii)=max(max(ZIg_all{ii}));
end
%----- Display Height Over Time : ---------------------------------------------------------------------------------------
n=0;figure;
fignum=0;
for ii=days(1):days(end)
    n=n+1;
    
    figure;
    %patchsurf3D(XIg_all{ii},YIg_all{ii},0,ZIg_all{ii},0);
    surf(XIg_all{ii},YIg_all{ii},ZIg_all{ii}*0,ZIg_all{ii});
    %pcolor(XIg_all{ii},YIg_all{ii},ZIg_all{ii});
    h=line(avx{ii},avy{ii}); set(h,'Color',[0 0 0],'LineWidth',2);
    view(0,90);caxis([min(min(ZIg_minimum)) max(max(ZIg_maximum))]); grid off; shading('flat');
    axis on
    axis equal; 
    axis([min(avx{ii})-50 max(max(avx{ii})+50,min(avx{ii})+1050) min(avy{ii})-50 max(avy{ii})+50]);
    nscale=1000;
    %title('click where you want the scale bar to be')
    %[x1,y1]=ginput(1);
    hold on,
    x1=min(avx{ii});
    y1= max(avy{ii})+20;
    h=line([x1;x1+nscale],[y1;y1]);
    set(h,'Color',[0 0 0]);
    
    %axis([-1000 1000 -600 600])
    
    axis off
    cd(PathName2);
    fignum=fignum+1;
    saveas(gcf, ['HeightDAS' num2str(ii) 'in2D.fig']);
    %saveas(gcf, ['HeightDAS' num2str(ii)],'epsc');
end

disp('Scale bars in all images represent 1mm');
% 
% set(gcf,'Name','Height');
% %cd('S:\Camille Girard-Bock\Shape paper_Summer2013\figures\Camille\Height');
% saveas(gcf, ['Height3.fig']);
% saveas(gcf, ['Height3'], 'png');
% saveas(gcf, ['Height3'], 'epsc');
% %save the scale bar:
 figure;
 caxis([min(min(ZIg_minimum)) max(max(ZIg_maximum))]);grid off;axis off;colorbar;
% 
% set(gcf,'Name','Height scale');
% %cd('S:\Camille Girard-Bock\Shape paper_Summer2013\figures\Camille\Height');
 saveas(gcf, ['Heightscale.fig']);
 
 disp(['Figures have been saved in ' PathName2 ' (names ending in ''in2D.fig)']);
% saveas(gcf, ['Heightscale3'], 'epsc');