%plot_lots_runs6
ndornot=1 % 0=full model, 1=no diaz
%%
% single species
if (ndornot==0), 
 runti  =[ 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 ...
          23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43   ...
          44 45 46 47 48 49 50 51];
 specrun=[ 1  2 22 23  5 35 36 37 13  6 38 39 40 34  7 41 42 43 44 45 46 47 ...
           0  0  0  8 48 49 50 51  0  0  0  0  0 19 52 53 54 55 56 57  0   ...
           0  0  0  0  0  0  0  0];

% auto, mixo, hetero+carn mixo+hetero+carn, carn (only), carn (none)
 runtt   =[ 1  2  3  4 5 6];
 runtroph=[98 10 16 17 20 21];
 
 runts  =[ 1  2  3  4  5  6  7  8  9 10 11 12 13];
 runsize=[ 1  2 22 23 24 25 26 27 28 29 30 31 32];
 
 runts2   =[ 1  2  3];
 runtsize2=[ 4 33 14];
 
 runtf  =[ 1  2  3  4  5];
 runfunc=[ 4 11  9 12 10];
else
 runti  =[ 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 ...
          23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43   ...
           44 45 46 47 48 49 50 51];
 specrun=[ 1  2 22 23  5  0  0  0 13  6  0  0  0  0  7  0  0  0  0  0  0  0 ...
           0  0  0  8  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   ...
            0  0  0  0  0  0  0  0];

% auto, mixo, hetero+carn mixo+hetero+carn, carn (only), carn (none)
 runtt   =[ 1  2  3  4   5  6];
 runtroph=[98 10 16 17  20 21];

 runts  =[ 1  2  3  4  5  6  7  8  9 10 11 12 13];
 runsize=[ 1  2 22 23 24 25 26 27 28 29 30 31 32];

 runts2   =[ 1  2  3];
 runtsize2=[ 4 33 14];

 runtf  =[ 1  2  3  4  5];
 runfunc=[ 4 11  9 12 10];
end


%%%%
minpp(99)=-100; maxpp(99)=-100; ppdiff(99)=-100;
minep(99)=-100; maxep(99)=-100; epdiff(99)=-100;
nfixarea(99)=-1; nfixdiff(99)=-100;
mingr(99)=-100; maxgr(99)=-100; grdiff(99)=-100;
maxcb(99)=1; cbmean(99)=1;
maxcbe(99)=1; cbemean(99)=1;
mintr(99)=-1; maxtr(99)=-1; trdiff(99)=-1;
miner(99)=-1; maxer(99)=-1; erdiff(99)=-1;
pparea(99,1:4)=100; eparea(99,1:3)=100; grarea(99,1:4)=100; cbearea(99,1:4)=100;
minldmmax(99)=NaN; maxldmmax(99)=NaN; ldmmaxdiff(99)=NaN;
minldmmean(99)=NaN; maxldmmean(99)=NaN;
ldmmeandiff(99)=NaN;



pltnt=1;
%%%%
if (pltnt==1),
for ityp=1:5,
 if (ityp==1), truns=specrun; trunst=runti; tstr='All types'; end
 if (ityp==2), truns=runtroph; trunst=runtt; tstr='Trophic Strategy'; end
 if (ityp==3), truns=runsize; trunst=runts; tstr='Size Classes'; end
 if (ityp==4), truns=runtsize2; trunst=runts2; tstr='Size Groups'; end
 if (ityp==5), truns=runfunc; trunst=runtf; tstr='Functional groups'; end
 w1=4; w2=2; ymin=-105; ymax=170;
 figure
 subplot(4,1,1),
 for irun=trunst;
  iirun=truns(irun)+1;
  if (iirun>1),
   plot([irun-.5 irun-.5],[minpp(iirun) maxpp(iirun)],'g-','LineWidth',w1);
   hold on
   plot([irun-.5 ],[ppdiff(iirun)],'ko','LineWidth',w2);
   plot([irun-.25 irun-.25],[minep(iirun) maxep(iirun)],'r-','LineWidth',w1);
   plot([irun-.25],[epdiff(iirun)],'ko','LineWidth',w2);
   plot([irun irun],[mingr(iirun)  maxgr(iirun)],'c-','LineWidth',w1);
   plot([irun],[grdiff(iirun)],'ko','LineWidth',w2);
   plot([irun+.25 irun+.25],[0 nfixarea(iirun)*100],'b-','LineWidth',w1);
   plot([irun+.25],[nfixdiff(iirun)],'bo','LineWidth',w2);
  end
  plot([irun+.35 irun+.35],[ymin ymax],'k:');
  if (ityp==1), 
    if (irun==4 | irun==9 | irun==14 | irun==25 | irun==35),
       plot([irun+.35 irun+.35],[ymin ymax],'k-','LineWidth',2);
    end
  end 
 end % for irun
 plot([0.35 max(trunst)+.35],[0 0],'k:');
 bolder
 axis([0.35 max(trunst)+.35 ymin ymax]);
 ylabel('% diff')
 if (ityp==2),
    set(gca,'Xtick',[.9:1:5.9]);
    set(gca,'XtickLabel',['A  ';'M  ';'Z  ';'M+Z';'Zc ';'C  ']);
 end
 if (ityp==3),
   set(gca,'Xtick',[.9:1:12.9]);
    set(gca,'XtickLabel',['0.6';'0.9';'1.4';'2.0';'3.0';'4.5';'6.6';'10 '; ...
    '15 ';'22 ';'32 ';'47 ';'70 ']); %;'104';'154']);
 end
 if (ityp==4),
    set(gca,'Xtick',[.9:1:2.9]);
    set(gca,'XtickLabel',['<3  ';'3-10';'>10 ']);
 end
 if (ityp==5),
    set(gca,'Xtick',[.9:1:5.9]);
    set(gca,'XtickLabel',['pico';'cocc';'diaz';'diat';'mixo']);
 end


 
 title(tstr);
%%
 subplot(4,1,2)
 for irun=trunst;
  iirun=truns(irun)+1;
  if (iirun>1),
   plot([irun-.25 irun-.25],[miner(iirun) maxer(iirun)],'y-','LineWidth',w1);
   hold on
   plot([irun-.25 ],[erdiff(iirun)],'ko','LineWidth',w2);
   plot([irun+.25 irun+.25],[0 maxcbe(iirun)],'m-','LineWidth',w1);
   plot([irun+.25],[cbemean(iirun)],'ko','LineWidth',w2);
   plot([irun irun],[mintr(iirun) maxtr(iirun)],'c-','LineWidth',w1);
   plot([irun ],[trdiff(iirun)],'ko','LineWidth',w2);
  end %
  plot([irun+.35 irun+.35],[-ymax ymax],'k:');
  if (ityp==1),
    if (irun==4 | irun==9 | irun==14 | irun==25 | irun==35),
       plot([irun+.35 irun+.35],[ymin ymax],'k-','LineWidth',2);
    end
  end
 end % for irun
 plot([0.35 max(trunst)+.35],[0 0],'k:');
 bolder
 axis([0.35 max(trunst)+.35 -1 1]);
 ylabel('B-C, ratio diff');
 if (ityp==2), 
    set(gca,'Xtick',[.9:1:5.9]);
    set(gca,'XtickLabel',['A  ';'M  ';'Z  ';'M+Z';'Zc ';'C  ']);
 end
 if (ityp==3),
   set(gca,'Xtick',[.9:1:12.9]);
    set(gca,'XtickLabel',['0.6';'0.9';'1.4';'2.0';'3.0';'4.5';'6.6';'10 '; ...
    '15 ';'22 ';'32 ';'47 '; '70 ']); %;'104';'154']);
 end
 if (ityp==4),
    set(gca,'Xtick',[.9:1:2.9]);
    set(gca,'XtickLabel',['<3  ';'3-10';'>10 ']);
 end
 if (ityp==5),
    set(gca,'Xtick',[.9:1:5.9]);
    set(gca,'XtickLabel',['pico';'cocc';'diaz';'diat';'mixo']);
 end



%%
 subplot(4,1,3)
 for irun=trunst;
  iirun=truns(irun)+1;
  if (iirun>1),
   plot([irun-.5 irun-.5],[0 pparea(iirun,1)],'g-','LineWidth',w1);
   hold on
   if (pparea(iirun,2)>0), 
    plot([irun-.5],[pparea(iirun,2)],'kx','LineWidth',w2);
   end % if
   if (pparea(iirun,3)>0),
    plot([irun-.5],[pparea(iirun,3)],'k*','LineWidth',w2+1);
   end % if
%  plot([irun-.5],[pparea(iirun,4)],'k+','LineWidth',w2+2);
   plot([irun-.25 irun-.25],[0 eparea(iirun,1)],'r-','LineWidth',w1);
   if (eparea(iirun,2)>0),
    plot([irun-.25],[eparea(iirun,2)],'kx','LineWidth',w2);
   end % if
   if (eparea(iirun,3)>0),
    plot([irun-.25],[eparea(iirun,3)],'k*','LineWidth',w2+1);
   end % if
 % plot([irun-.25],[eparea(iirun,4)],'k+','LineWidth',w2+2);
   plot([irun irun],[0 grarea(iirun,1)],'c-','LineWidth',w1);
   if (grarea(iirun,2)>0),
    plot([irun],[grarea(iirun,2)],'kx','LineWidth',w2);
   end % if
   if (grarea(iirun,3)>0),
    plot([irun],[grarea(iirun,3)],'k*','LineWidth',w2+1);
   end % if
 % plot([irun],[grarea(iirun,4)],'k+','LineWidth',w2+2);
   plot([irun+.25 irun+.25],[0 cbearea(iirun,1)],'m-','LineWidth',w1);
   if (cbearea(iirun,2)>0),
    plot([irun+.25],[cbearea(iirun,2)],'kx','LineWidth',w2);
   end % if
   if (cbearea(iirun,3)>0),
    plot([irun+.25],[cbearea(iirun,3)],'kx','LineWidth',w2+1);
   end % if
 % plot([irun],[cbearea(iirun,4)],'kx','LineWidth',w2+2);
  end % iirun
  plot([irun+.35 irun+.35],[-ymax ymax],'k:');
  if (ityp==1),
    if (irun==4 | irun==9 | irun==14 | irun==25 | irun==35),
       plot([irun+.35 irun+.35],[ymin ymax],'k-','LineWidth',2);
    end
  end
 end % for irun
 plot([0.35 max(trunst)+.35],[0 0],'k:');
 bolder
 axis([0.35 max(trunst)+.35 0 100]);
 ylabel(['% area'])
 if (ityp==2),
    set(gca,'Xtick',[.9:1:5.9]);
    set(gca,'XtickLabel',['A  ';'M  ';'Z  ';'M+Z';'Zc ';'C  ']);
 end
 if (ityp==3),
   set(gca,'Xtick',[.9:1:12.9]);
    set(gca,'XtickLabel',['0.6';'0.9';'1.4';'2.0';'3.0';'4.5';'6.6';'10 '; ...
    '15 ';'22 ';'32 ';'47 ';'70 ']); %;'104';'154']);
 end
 if (ityp==4),
    set(gca,'Xtick',[.9:1:2.9]);
    set(gca,'XtickLabel',['<3  ';'3-10';'>10 ']);
 end
 if (ityp==5),
    set(gca,'Xtick',[.9:1:5.9]);
    set(gca,'XtickLabel',['pico';'cocc';'diaz';'diat';'mixo']);
 end

 subplot(4,1,4)
 for irun=trunst;
  iirun=truns(irun)+1;
  if (iirun>1),
%   plot([irun-.5 irun-.5],[minldmmax(iirun) maxldmmax(iirun)],'y-','LineWidth',w1);
    hold on
    plot([irun-.5],[ldmmaxdiff(iirun)],'bo','LineWidth',w2);
    plot([irun-.1 irun-.1],[minldmmean(iirun)  maxldmmean(iirun)],'y-','LineWidth',w1);
    plot([irun-.1],[ldmmeandiff(iirun)],'ko','LineWidth',w2);
  end % iirun
  plot([irun+.35 irun+.35],[-ymax ymax],'k:');
  if (ityp==1),
    if (irun==4 | irun==9 | irun==14 | irun==25 | irun==35),
       plot([irun+.35 irun+.35],[ymin ymax],'k-','LineWidth',2);
    end
  end
 end % for irun
 plot([0.35 max(trunst)+.35],[0 0],'k:');
 bolder
 axis([0.35 max(trunst)+.35 -10 10]);
 ylabel(['\Delta ESD'])
 if (ityp==2),
    set(gca,'Xtick',[.9:1:5.9]);
    set(gca,'XtickLabel',['A  ';'M  ';'Z  ';'M+Z';'Zc ';'C  ']);
 end
 if (ityp==3),
    set(gca,'Xtick',[.9:1:12.9]);
    set(gca,'XtickLabel',['0.6';'0.9';'1.4';'2.0';'3.0';'4.5';'6.6';'10 '; ...
    '15 ';'22 ';'32 ';'47 ';'70 ']); % ';'104';'154']);
 end
 if (ityp==4),
    set(gca,'Xtick',[.9:1:2.9]);
    set(gca,'XtickLabel',['<3  ';'3-10';'>10 ']);
 end
 if (ityp==5),
    set(gca,'Xtick',[.9:1:5.9]);
    set(gca,'XtickLabel',['pico';'cocc';'diaz';'diat';'mixo']);
 end



end % for ityp

end % pltnt
