% I don't know what went wrong with the code above, but this is what I
% wanted to show. The graphs overlap and I don't know how to fix this.
figure (4);
t = tiledlayout(2,4);
nexttile
x1 = [1,2,3,4,5,6,7,8,9,10,11,11,10,9,8,7,6,5,4,3];
y1 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
x2 = [2,5,6,7,5,6,7,10,9,10,11,11,10,9,7,7,7,7,7,7];
y2 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
ax1 = axes(t);
plot(ax1,x1,y1,'-','lineWidth', 2,'Color',[0.6350 0.0780 0.1840]);
set(gca,'Ydir','reverse');
ylabel('Depth (m)');
xlabel('Temperature (C)');
ax1.XColor = [0.6350 0.0780 0.1840];
ax1.YColor = 'k';
ax2 = axes(t);
plot(ax2,x2,y2,'-','lineWidth', 2,'Color',[0 0.4470 0.7410]);
set(gca,'Ydir','reverse');
ax2.XAxisLocation = 'top';
ax2.YAxisLocation = 'right';
variableYaxis = ax2.YAxis; % Define the y-axis as a variable
variableYaxis.Visible = 'off'; % Turn off variable visibility
xlabel('Salinity (PSU)');
ax2.XColor = [0 0.4470 0.7410];
ax2.Color = 'none';
ax1.Box = 'off';
ax2.Box = 'off';
nexttile
ax1 = axes(t);
plot(ax1,x1,y1,'-','lineWidth', 2,'Color',[0.6350 0.0780 0.1840]);
set(gca,'Ydir','reverse');
ylabel('Depth (m)');
xlabel('Temperature (C)');
ax1.XColor = [0.6350 0.0780 0.1840];
ax1.YColor = 'k';
ax2 = axes(t);
plot(ax2,x2,y2,'-','lineWidth', 2,'Color',[0 0.4470 0.7410]);
set(gca,'Ydir','reverse');
ax2.XAxisLocation = 'top';
ax2.YAxisLocation = 'right';
variableYaxis = ax2.YAxis; % Define the y-axis as a variable
variableYaxis.Visible = 'off'; % Turn off variable visibility
xlabel('Salinity (PSU)');
ax2.XColor = [0 0.4470 0.7410];
ax2.Color = 'none';
ax1.Box = 'off';
ax2.Box = 'off';
