function ax = plotCryoData(tbl, tStart, tEnd) % plotCryoData Plot cryo cell data in 3 stacked panels with shared datetime axis. % % [ax] = plotCryoData(tbl, tStart, tEnd) % Returns struct with handles to the 3 axes for easy limit modification. %--- Extract datetime column --- dt = tbl.datetime; %--- If start/stop provided, subset the table --- if nargin >= 3 && ~isempty(tStart) && ~isempty(tEnd) mask = dt >= tStart & dt <= tEnd; tbl = tbl(mask, :); dt = dt(mask); end %--- Create tiled layout --- figure; tl = tiledlayout(4, 1); tl.TileSpacing = 'compact'; tl.Padding = 'compact'; %--- Upper tile: pressure and temperature (spans 2 rows) --- ax.pressure_temp = nexttile([2 1]); yyaxis left; plot(dt, tbl.pressure_cell_hPa_, 'o', 'MarkerSize', 2, 'MarkerFaceColor', 'auto'); ylabel('Pressure [hPa]'); ylim padded; grid on; yyaxis right; plot(dt, tbl.temperature__C_, 'o', 'MarkerSize', 2, 'MarkerFaceColor', 'auto'); ylabel('Temperature [°C]'); ylim padded; title('Pressure and Temperature'); set(gca, 'XTickLabel', []); %--- Middle tile: x, y, z with dual y-axes --- ax.xyz = nexttile; yyaxis left; plot(dt, tbl.y_mm_, 'o', 'MarkerSize', 2, 'MarkerFaceColor', 'auto', 'DisplayName', 'y'); hold on; ylabel('Y [mm]'); ylim([10 15]); grid on; yyaxis right; plot(dt, tbl.x_mm_, 's', 'MarkerSize', 2, 'MarkerFaceColor', 'auto', 'DisplayName', 'x'); hold on; plot(dt, tbl.z_mm_, '^', 'MarkerSize', 2, 'MarkerFaceColor', 'auto', 'DisplayName', 'z'); ylabel('X, Z [mm]'); ylim([-2 2]); legend({'y', 'x', 'z'}, 'Location', 'best'); set(gca, 'XTickLabel', []); %--- Lower tile: flowCryo --- ax.flow = nexttile; plot(dt, tbl.flowCryo_l_min_, 'o', 'MarkerSize', 2, 'MarkerFaceColor', 'auto'); grid on; ylabel('Flow [L/min]'); xlabel('Date & Time'); title('Cryo Flow'); %--- Link x-axes for all tiles --- linkaxes([ax.pressure_temp, ax.xyz, ax.flow], 'x'); % Improve datetime formatting on x-axis ax.flow.XAxis.TickLabelFormat = 'dd-MMM HH:mm'; end