function QCJPDF = QCFigureFunction1(s,missionID)
    %% Flip depth sign
    if mean(s.depth,'all','omitmissing') < 0
        s.depth = -s.depth;
    end
    %% Create variables
    % pHin Corrected and QC'd
    pHcorr = s.pHcorr; % Drift adjustment applied
    pHcorr(pHcorr == -999) = nan;
    
    % pHin CanyonB estimate and QC'd
    pHin_CanB = s.pHin_canb;
    pHin_CanB(pHin_CanB == -999) = nan;

    % pHin QC'd
    pHin = s.pHin; % Drift adjustment applied
    pHin(pHin == -999) = nan;
    
    pHincanB_residuals = pHin - pHin_CanB; % No correction applied
    pHcorrcanB_residuals = pHcorr - pHin_CanB; % Correction applied
    
    depthidx = s.depth >= 440 & s.depth <= 460; % Depth of correction    
    mn_noadj = mean(pHincanB_residuals(depthidx),'all','omitmissing');
    mn_adj = mean(pHcorrcanB_residuals(depthidx),'all','omitmissing');
    %% Plotting: JPDF Residuals vs Depth
    % cla; clf;
    QCJPDF = figure;
    tl = tiledlayout(1,2,"TileSpacing","compact","Padding","tight");
    title(tl,['Joint-PDF of pH Residuals vs depth for deployment ',char(missionID)]);
    ylabel(tl,'Depth (m)')
    xlabel(tl,'pH - CanyonB')
    
    nexttile
    hold on;
    h1 = histogram2(pHincanB_residuals,s.depth,"Normalization","pdf",...
        "DisplayStyle","tile",'FaceColor','flat','BinWidth',[.01 10]);
    set(gca,'Ydir','reverse')
    grid on
    title('Pre-Correction')
    xline(0,'k-','LineWidth',1)
    shading("interp")
    % clim([0 .04])
    scatter(mn_noadj,450,'o','filled','red')
    legend('','',['mean 440-460m pHin: ', num2str(mn_noadj)],'FontSize',6,Location='northwest');
    ylim([0 round(max(s.depth,[],'all'),0)])

    nexttile
    hold on;
    h2 = histogram2(pHcorrcanB_residuals,s.depth,"Normalization","pdf",...
        "DisplayStyle","tile",'FaceColor','flat','BinWidth',[.01 10]);
    set(gca,'Ydir','reverse')
    cb = colorbar;
    cb.Label.String = 'Probability Density';
    grid on
    title('Post-Correction')
    xline(0,'k-','LineWidth',1)
    shading("interp")
    % clim([0 .04])
    scatter(mn_adj,450,'o','filled','red')
    legend('','',['mean 440-460m pHcorr: ', num2str(mn_adj)],'FontSize',6,Location='northwest')
    ylim([0 round(max(s.depth,[],'all'),0)]) % Set ylim to max depth

    % Link axes for same x and y limits
    ax = findall(QCJPDF, 'Type', 'axes');
    linkaxes(ax, 'xy');
    xMax = max(abs([xlim(ax(1))]));
    xlim(ax, [-xMax, xMax]);

    % Synchronize color limits across the two plots
    clim = [0, max([h1.Values(:); h2.Values(:)])]; % Determine common CLim range
    set(ax, 'CLim', clim);

    % fsavename = fullfile('C:','Users','bwerb','Documents','SprayDataCorrections','FinalCorrectionFigures',['missionID_',char(missionIDs(i))]);
    % set(gcf, 'PaperOrientation', 'landscape');
    % set(gcf, 'PaperUnits', 'inches');
    % set(gcf, 'PaperSize', [11 8.5]); % Standard letter size in landscape
    % set(gcf, 'PaperPosition', [0 0 11 8.5]); % Fill the whole paper
    % saveas(fig,fsavename,'png')
    % disp(['Finished ',num2str(i), ' / ', num2str(length(missionIDs))])
    % close('all')
end