%subplothan=get(fig1,'Children');

%handle fig1 multiple wavelength graphs
for i=1:4
   
   %handle plot for Es and draw deploydates if Es exists(by EsLeg)
   if i==1&exist('EsLeg','var')
         maxi=get(subplot(4,1,i),'YLim');
  			mini=min(maxi);
         maxi=max(maxi);
           
         		%For Y axis
         		if mini>0 
      				mini=mini;
   				else
      				mini=0;
               end;
               if maxi>maxEsy
                  maxi=maxEsy;
               end;
        
               axis([(min(X.t)-3) (max(X.t)+3) mini maxi]);
               set(subplot(4,1,i),'XGrid','on','YGrid','on','YTick',[mini:25:maxi],'XTickLabel','','XTick',dates,'XTickLabel',datestr(dates,12),'Fontsize',8);
               
               %draw deploy dates
				   for j=1:(length(deploy_dates))
      			subplot(4,1,i);
               plot([deploy_dates(j) deploy_dates(j)],[mini maxi],'k','Linewidth',2);
               
               	if j<=(length(deploy_dates)-1)
                     text(deploy_dates(j),(maxi*1.05),num2str(Prr620(j)),'Fontsize',8);
                  end;   
                  
               end;
               
               
        			title([upper(p(1:3)),' Surface Irradiance'],'Fontweight','bold','Fontsize',8,'position',[729200 180.5 17.3205]);
					YLabel('uwatts/cm^2/nm','Fontweight','bold','Fontsize',8);
   

         
     %handle plot for Ed and draw deploydates if Ed exists(by EdLeg)    
     elseif i==2&exist('EdLeg','var')
            maxi=get(subplot(4,1,i),'YLim');
  				mini=min(maxi);
         	maxi=max(maxi);
            
              %For Y axis
         		if mini>0 
      				mini=mini;
   				else
      				mini=0;
               end;
               
               if maxi>maxEdy
                  maxi=maxEdy;
               end;
               
               %special axis for low wavelengths
               if min(find(boxval==1))>5
                  maxi=0.15;
               end;
               
        
               axis([(min(X.t)-3) (max(X.t)+3) mini maxi])
               set(subplot(4,1,i),'XGrid','on','YGrid','on','YTick',[mini:20:maxi],'XTickLabel','','XTick',dates,'XTickLabel',datestr(dates,12),'Fontsize',8);
               
               %draw deploy dates
				   for j=1:(length(deploy_dates))
      			subplot(4,1,i);
               plot([deploy_dates(j) deploy_dates(j)],[mini maxi],'k','Linewidth',2);
               
               	if j<=(length(deploy_dates)-1)
                  	text(deploy_dates(j),(maxi*1.05),num2str(Prr600(j)),'Fontsize',8);
               	end;
               
               end;
               
         		
               title([upper(p(1:3)),' 20M Irradiance'],'Fontweight','bold','Fontsize',8,'position',[729200 100.5 17.3205]);
               YLabel('uwatts/cm^2/nm','Fontweight','bold','Fontsize',8);

%handle plot for Lu and draw deploydates if Lu exists(by LuLeg)
     elseif i==3&exist('LuLeg','var')
            maxi=get(subplot(4,1,i),'YLim');
  				mini=min(maxi);
        		 maxi=2.25;
               
               %for Y axis
         		if mini>0 
      				mini=mini;
   				else
      				mini=0;
               end;
               
               if maxi>maxLuy
                  maxi=maxLuy;
               end;
               
               %special axis for low wavelengths
               if min(find(boxval==1))>5
                  maxi=0.02;
               end;

        
           		axis([(min(X.t)-3) (max(X.t)+3) mini maxi])
               set(subplot(4,1,i),'XGrid','on','YGrid','on','YTick',[mini:0.25:maxi],'XTickLabel','','XTick',dates,'XTickLabel',datestr(dates,12),'Fontsize',8);
               
               %draw deploy dates
				   for j=1:(length(deploy_dates))
      			subplot(4,1,i);
               plot([deploy_dates(j) deploy_dates(j)],[mini maxi],'k','Linewidth',2);
               
               		if j<=(length(deploy_dates)-1)
                        text(deploy_dates(j),(maxi*1.05),num2str(Prr600(j)),'Fontsize',8);
                     end;
               end;
               
         	 	
              title([upper(p(1:3)),' 20M Radiance'],'Fontweight','bold','Fontsize',8,'position',[729200 2 17.3205]);
              YLabel('uwatts/cm^2/nm','Fontweight','bold','Fontsize',8);
               
     %handle pressure plot          
  elseif i==4&get(boxhandle(2),'value')==1
      		maxi=get(subplot(4,1,i),'YLim');
  				mini=min(maxi);
        		maxi=max(maxi);
               
               %for Y axis
         		if mini>0 
      				mini=mini;
   				else
      				mini=0;
               end;
               
					axis([(min(X.t)-3) (max(X.t)+3) mini maxi])
               set(subplot(4,1,i),'XGrid','on','YGrid','on','XTickLabel','','XTick',dates,'XTickLabel',datestr(dates,12),'FontSize',8,'YDir','reverse');
               
               for j=1:(length(deploy_dates))
      			subplot(4,1,i);
               plot([deploy_dates(j) deploy_dates(j)],[mini maxi],'k','Linewidth',2);
            	end;
            	
               title([upper(p(1:3)),' Pressure'],'Fontweight','bold','Fontsize',8,'Position',[729175 -2.1 17.3205]);
      
     end;
 end;
         
   
   
  %handle the legends
if exist('EsLeg','var')
subplot(4,1,1)
legend(EsLeg,-1);
end;
if exist('EdLeg','var')
subplot(4,1,2);
legend(EdLeg,-1);
end;
if exist('LuLeg','var')
subplot(4,1,3);
legend(LuLeg,-1);
end;
if get(boxhandle(2),'value')==1
   subplot(4,1,4);
   legend('Db',-1);
end;