Hi Eileen,
To achieve titles for each column and row of subplots, you can manually add text annotations to the figure. This allows you to place titles exactly where you want them.
The below code demonstrates how to achieve this using dummy data:
% Create a figure
figure;
% Create a 2x2 grid of subplots for demonstration
subplot(2, 2, 1);
plot(rand(10, 1));
title('Plot 1');
subplot(2, 2, 2);
plot(rand(10, 1));
title('Plot 2');
subplot(2, 2, 3);
plot(rand(10, 1));
title('Plot 3');
subplot(2, 2, 4);
plot(rand(10, 1));
title('Plot 4');
% Add row titles
annotation('textbox', [0.01, 0.75, 0.1, 0.1], 'String', 'Row 1', 'EdgeColor', 'none', 'FontSize', 12, 'FontWeight', 'bold');
annotation('textbox', [0.01, 0.25, 0.1, 0.1], 'String', 'Row 2', 'EdgeColor', 'none', 'FontSize', 12, 'FontWeight', 'bold');
% Add column titles
annotation('textbox', [0.3, 0.95, 0.1, 0.1], 'String', 'Column 1', 'EdgeColor', 'none', 'FontSize', 12, 'FontWeight', 'bold');
annotation('textbox', [0.7, 0.95, 0.1, 0.1], 'String', 'Column 2', 'EdgeColor', 'none', 'FontSize', 12, 'FontWeight', 'bold');
For more details, please refer to the following MathWorks documentations:
- Create axes in tiled positions - https://www.mathworks.com/help/matlab/ref/subplot.html
- Create annotations - https://www.mathworks.com/help/matlab/ref/annotation.html
Hope this helps!