function [m]=getMCLbarplots(VVol,d,transects,zinterpd,zthresh,normyear,data,curdir,routine);

for i=1:size(VVol,2)
    years(i)=str2num(VVol(1,i).year);
end

zid=zinterpd;

first=find(years<=normyear);
last=find(years>normyear);

depfname=input('what is the directory of the batchresults.txt?','s')
eval(['depdata=load(''D:\UCIT_Projects\' depfname '\batchresults.txt'');'])
trans=unique(depdata(:,3));


for i=1:size(VVol,1)
    for j=1:size(VVol,2)
        pid=find(depdata(:,1)==years(j) & depdata(:,3)==str2num(transects(i,:)));
        if pid
            dep(i,j)=depdata(pid(1),8);
        else
            dep(i,j)=NaN;
        end
        dateyear(i,j)=VVol(i,j).yeardate;
    end
end

for i=1:size(dep,1)
P1_tot(i,1:2)=polyfit(dateyear(i,zid(i,first)>=zthresh),dep(i,zid(i,first)>=zthresh),1);
P2_tot(i,1:2)=polyfit(dateyear(i,zid(i,last)>=zthresh),dep(i,zid(i,last)>=zthresh),1);
end
m=[P1_tot(:,1) P2_tot(:,1)];


figure(8)
orient tall
clf
subplot(311)
bar(str2num(transects),m(:,1),0.5)
%axis tight
% xlim([3190 4010])
% ylim([-7 7])
ylabel('DEP Trend (m/y)')
title('Trend in the Dune Erosion Point (DEP)')
eval(['lh=legend(''' num2str(min(years)) '-' num2str(normyear) ''',''Location'',''NorthEast'',''Orientation'',''horizontal'')'])
set(lh,'fontsize',8)
legend boxoff
hold on
axis tight
xlim([str2num(transects(1,:))-5 str2num(transects(end,:))+5])
% plot([3325 3325],[-150 160],'b--','linewidth',2)
% plot([3800 3800],[-150 160],'r--','linewidth',2)
subplot(312)
bar(str2num(transects),m(:,2),0.5)
%axis tight
% xlim([3190 4010])
% ylim([-7 7])
ylabel('DEP Trend (m/y)')
%colormap summer
eval(['lh=legend(''' num2str(normyear+1) '-' num2str(max(years)) ''',''Location'',''NorthEast'',''Orientation'',''horizontal'')'])
set(lh,'fontsize',8)
legend boxoff
hold on
axis tight
xlim([str2num(transects(1,:))-5 str2num(transects(end,:))+5])
% plot([3325 3325],[-150 160],'b--','linewidth',2)
% plot([3800 3800],[-150 160],'r--','linewidth',2)


for i = 1:length(str2num(transects))
    for j= 1:length(years)
        [nourished, amountperyear]=getNourishmentInfo(data,str2num(VVol(i,j).areacode),transects(i,:),years(j));
        storagevar(i,j)=sum(amountperyear);
    end
end

storagevar(isnan(storagevar))=0;
id=find(sum(storagevar,1)~=0);
year=years(id);
if isempty(id)==0
    storagevar=storagevar(:,id);
end

figure(8)
subplot(313)
bh=bar(str2num(transects),storagevar,0.5,'stack');
if isempty(id)==0
    for i = 1:length(year)
        legendtext{1,i}=num2str(year(i));
    end
    lh=legend(bh,legendtext);
    set(lh,'fontsize',8);
    set(lh,'location','NorthOutside','orientation','horizontal');
end
%legend boxoff
% lh2=axes;
% axis off;
% set(lh2,'position',[0.065 0.280 0.87 0.0263158],'xtick',[],'ytick',[]);
% copyobj(get(lh,'children'),lh2);
% delete(lh);
% lh3=get(lh,'children');
% types=get(lh3,'type')
% for i=1:length(lh3)
%     lh4=get(lh3(i),'children');
%     set(lh4,'MarkerSize',.1);
% end
xlabel('Transect ID')
ylabel([{'Cumulative Nourishment'};{'(m^3/m)'}])
axis tight
xlim([str2num(transects(1,:))-5 str2num(transects(end,:))+5])
legend  boxoff
% axis tight
% xlim([3190 4010])
% ylim([0 3000])
%cd curdir
%cd 'D:\verhuur\ucit_data\UCIT\Egmond Bergen\'
cd (curdir)
eval(['print -dpng SlopeofDEPBarplot_' VVol(1,1).areacode '_' VVol(1,1).transectID '-' VVol(end,1).areacode '_' VVol(end,1).transectID ])
