2
votes

I am creating a 3x1 outer plot in Matlab. Within each outer plot I want to have a 5x1 inner plot. For every 3x1 outer plot, I want separate y axis labels. I also want each 5x1 inner plot to have its own y-axis label. All plots will have the same x-axis label.

I have been using Matlab's tiledlayout function. I am struggling with how to create the nested 5x1 inner plots though and how to give each inner plot its own distinct label. This is what I have so far:

close all
f = figure;
subj_plot = tiledlayout(3,1);


% Iterate through all subject

for subj = 1:3
    nexttile
    ylabel(['\bf Subject', num2str(subj)]);
    for fing = 1:5

    end

end
xlabel('test');
subj_plot.TileSpacing = 'compact';

Overall the figure will be 15x1 with groupings of 3x1. I am not sure how to set this up, and how to nest a tiled layout figure within a figure with distinct labels using hold on. I How can I do this?

EDIT: each individual 15x1 plot will have two graphs over-layed on each other.

EDIT2: DESIRED STRUCTURE WITH DIMENSIONS REDUCED

1
Consider using subplot instead of tiledlayout. More flexibility and ability to address individual sub-plot axes. - mhopeng
Correct me if I'm wrong, but subplot does not provide a way to provide yaxis labels for grouped subplots which is what I need. - J_code
HI J_code, I think my workflow has something quite similar to what you might want. I'm finding it hard to understand what your desired goal is based on your explanation, so could you make a sketch of what it is your want your final result to look like? - Michael
@Michael See EDIT2 above. I've drawn it with reduced dimensions so that you can easily see the desired structure I want using tiledlayout - J_code

1 Answers

0
votes

I don't have the function tiledlayout (my Matlab is older than R2019b) so I cannot reproduce this exactly. I would consider using text as opposed to ylabel for the outer plots, something like this:

% define ax = get axis for each subplots in your tiled layout
ax.Units = 'pixels'; 
h = text(ax.Position(1)+ax.Position(3)/2, ax.Position(2)+ax.Position(4)/2, 'Your Outer Axis Label', 'Units', 'pixels', 'HorizontalAlignment', 'center', 'Rotation', 90);

You could of course drag the text manually too if reproducibility is not a concern here.