
function qcOA1_plotAll(pos,co2,ph,temp,sal,press,dens,o2,fluor,met,metw)

% pos = Position;
% co2 = CO2;
% o2= oxygen;
% temp = temperature;
% sal= salinity;
% dens = density
% fluor = fluorescence;
% met = MET;
% metw = METw;

% -- 
% Jeff Sevadjian
% Research Technician
% Monterey Bay Aquarium Research Institute
% 7700 Sandholdt Rd
% Moss Landing, CA 95039, USA
% ph: +1 831-775-1888

% Makes a figure similar to the webQC page

%modified for OCSD by Diego Sancho, 6/2020

%colormap
 myCol = [
   100 100 100; ... %gray
   11 99 160; ... %blue
   255 127 14; ... %orange
   44, 160, 44; ... %green
   50 50 50; ... %dark gray
   134 159 192; ... %lt. blue
   20 20 20] ... %black
   / 255;

%axes param's
 %all axes
  timeAll = [pos(:,1); co2(:,1); temp(:,1); sal(:,1); dens(:,1); o2(:,1); fluor(:,1); met(:,1); metw(:,1)];
  ax.XLim = [min(timeAll) max(timeAll)];
  ax.XTickLabel = [];
  ax.Box = 'off';
 %secondary axes
  ax2.Color = 'none';
  ax2.XAxisLocation = 'top';
  ax2.YAxisLocation = 'right';
  ax2.XTickLabel = [];
 %tertiary axes
  ax3.Color = 'none';
  ax3.XTick = [];
  ax3.YTick = [];
  ax3.YAxisLocation = 'right';
  ax3.XColor = 'none';
  %y-axis for tertiary
   ax4.Color = 'none';
   ax4.XTick = [];
   ax4.YAxisLocation = 'right';
   ax4.XColor = 'none';

%create fig
 figure('Name','All','Units','inches','Position',[0 0 11 8.5]);
 ha = tight_subplot(10,1,0.03,0.05,0.15);

%Position
 axes(ha(1));
 %lon
  plot(pos(:,1),pos(:,2),'.-','Color',myCol(1,:));
  ylabel(['Lon [' char(186) 'E]']);
  set(ha(1),ax,'YColor',myCol(1,:),'YLim',[min(pos(:,2)) max(pos(:,2))]);
 %lat
  ha1a = axes;
  plot(pos(:,1),pos(:,3),'.-','Color',myCol(2,:));
  ylabel(['Lat [' char(186) 'N]']);
  set(ha1a,ax,ax2,'Position',get(ha(1),'Position'),...
    'XTick',get(ha(1),'XTick'),'YColor',myCol(2,:),...
    'YLim',[min(pos(:,3)) max(pos(:,3))]);

%temp
 axes(ha(2));
 %temp
  plot(temp(:,1),temp(:,2),'.-','Color',myCol(2,:));
  ylabel(['T [' char(186) 'C]']);
  set(ha(2),ax,'YColor',myCol(2,:),'YLim',[min(temp(:,4)) max(temp(:,2))]);
  hold on
  plot(temp(:,1),temp(:,3),'.-','Color',myCol(3,:));
  hold on
  plot(temp(:,1),temp(:,4),'.-','Color',myCol(4,:));
  set(ha(2),ax,'XTick',get(ha(2),'XTick'),'YColor','k',...
    'YLim',[min(temp(:,4)) max(temp(:,2))]);
  legend('5m', '35m', '60m','Location','best','Orientation','Horizontal')

  %salinity
  axes(ha(3));
 %sal
  plot(sal(:,1),sal(:,2),'.-','Color',myCol(2,:));
  ylabel(['Salinty [psu]']);
  set(ha(3),ax,'YColor',myCol(2,:),'YLim',[min(sal(:,4)) max(sal(:,2))]);
  hold on
  plot(sal(:,1),sal(:,3),'.-','Color',myCol(3,:));
  hold on
  plot(sal(:,1),sal(:,4),'.-','Color',myCol(4,:));
  set(ha(3),ax,'XTick',get(ha(3),'XTick'),'YColor','k',...
    'YLim',[min(sal(:,4)) max(sal(:,2))]);
  legend('5m', '35m', '60m','Location','best','Orientation','Horizontal')
  
  %density
  axes(ha(4));

  plot(dens(:,1),dens(:,2),'.-','Color',myCol(2,:));
  ylabel(['Density [kg/m^3]']);
  set(ha(4),ax,'YColor',myCol(2,:),'YLim',[min(dens(:,2)) max(dens(:,4))]);
  hold on
  plot(dens(:,1),dens(:,3),'.-','Color',myCol(3,:));
  hold on
  plot(dens(:,1),dens(:,4),'.-','Color',myCol(4,:));
  set(ha(4),ax,'XTick',get(ha(4),'XTick'),'YColor','k',...
    'YLim',[min(dens(:,2)) max(dens(:,4))]);
  legend('5m', '35m', '60m','Location','best','Orientation','Horizontal')
  
  %pressure
  axes(ha(5));

  plot(press(:,1),press(:,2),'.-','Color',myCol(2,:));
  ylabel(['pressura [dbar]']);
  set(ha(5),ax,'YColor',myCol(2,:),'YLim',[min(press(:,2)) max(press(:,4))]);
  hold on
  plot(press(:,1),press(:,3),'.-','Color',myCol(3,:));
  hold on
  plot(press(:,1),press(:,4),'.-','Color',myCol(4,:));
  set(ha(5),ax,'XTick',get(ha(5),'XTick'),'YColor','k',...
    'YLim',[min(press(:,2)) max(press(:,4))]);
  legend('5m', '35m', '60m','Location','best','Orientation','Horizontal')
  
 %o2
  axes(ha(6)); 
  plot(o2(:,1),o2(:,2),'.-','Color',myCol(2,:));
  hold on
  plot(o2(:,1),o2(:,3),'.-','Color',myCol(3,:));
  hold on
  plot(o2(:,1),o2(:,4),'.-','Color',myCol(4,:));
  set(ha(6),ax,'YColor','k','YLim',[min(o2(:,4)) max(o2(:,2))]);
  ylabel(['O2 [' char(181) 'mol/kg]']);
  legend('5m', '35m', '60m','Location','best','Orientation','Horizontal')

 
%pCO2
 axes(ha(7));
  %pH
   plot(ph(:,1),ph(:,2),'.-','Color',myCol(2,:));
   hold on
   plot(ph(:,1),ph(:,3),'.-','Color',myCol(3,:));
   if size(ph,2)>3
       hold on
       plot(ph(:,1),ph(:,4),'.-','Color',myCol(4,:));
       legend('5m','35m','60m');
   end
   legend('35m','60m')
   ylabel('pH');
      set(ha(7),ax,'YColor',myCol(7,:));
   try set(ha(7),'YLim',[min(co2(:,2)) max(co2(:,2))]); end
  %pCO2
   %water
    if size(co2,2)>3
        ha7a = axes;
        f = find(~isnan(co2(:,4)));
        plot(co2(f,1),co2(f,4),'.-','Color',myCol(2,:));
        ylabel('pCO2 [ppm]');
        set(ha7a,ax,ax2,'Position',get(ha(7),'Position'),...
            'XTick',get(ha(7),'XTick'),'YColor',myCol(2,:),...
            'NextPlot','add','YLim',[min(min(co2(:,3:4))) max(max(co2(:,3:4)))]);
    
   %air
        f = find(~isnan(co2(:,3)));
        plot(co2(f,1),co2(f,3),'.-','Color',myCol(6,:));
    else 
        disp('missing or empty CO2 array')
    end
    clear f;

%Fluorometer
 axes(ha(8));
  %fluor
   plot(fluor(:,1),fluor(:,2),'.-','Color',myCol(4,:));
   ylabel(['Fluor [' char(181) 'g/l]']);
   set(ha(8),ax,'YColor',myCol(4,:),'YLim',[min(fluor(:,2)) max(fluor(:,2))]);

   %
   
%Wind
 axes(ha(9));
  %dir
   plot(metw(:,1),metw(:,2),'.','Color',myCol(1,:));
   ylabel('Wind Dir');
   set(ha(9),ax,'YColor',myCol(1,:));
   try set(ha(9),'YLim',[min(metw(:,2)) max(metw(:,2))]); end
  %speed
   ha9a = axes;
   plot(metw(:,1),metw(:,3),'.-','Color',myCol(2,:));
   ylabel('Speed [m/s]');
   set(ha9a,ax,ax2,'Position',get(ha(9),'Position'),...
     'XTick',get(ha(9),'XTick'),'YColor',myCol(2,:));
   try set(ha9a,'YLim',[min(metw(:,3)) max(metw(:,3))]); end

%MET
 axes(ha(10));
  %press
   plot(met(:,1),met(:,2),'.-','Color',myCol(1,:));
   ylabel('Press [hPa]');
   set(ha(10),ax,'YColor',myCol(1,:));
   try set(ha(10),'YLim',[min(met(:,2)) max(met(:,2))]); end
  %temp
   ha10a = axes;
   plot(met(:,1),met(:,3),'.-','Color',myCol(2,:));
   ylabel(['Temp [' char(186) 'C]']);
   set(ha10a,ax,ax2,'Position',get(ha(10),'Position'),...
     'XTick',get(ha(10),'XTick'),'YColor',myCol(2,:));
   try set(ha10a,'YLim',[min(met(:,3)) max(met(:,3))]); end

%TagID - to do
%  axes(ha(11));
%  set(ha(11),ax);
 datetick(ha(10),'x','mm/yy')
 
%link axes
if exist('ha7a','var') == 1
 linkaxes([ha',ha1a,ha7a,ha9a,ha10a],'x');
else
    linkaxes([ha',ha1a,ha9a,ha10a],'x');
end

    
 