-2

I've got a tiled layout in MATLAB with 3 tiles and I want to add a vertical label left to the y-axis, spanning over all tiles.

figure('units','normalized','outerposition',[0 0 0.4 0.91])
tlo = tiledlayout(3,1,'TileSpacing','none','Padding','none');
nexttile
set(gca,'XColor','none')
hold on
plot(x1)
hold off
nexttile
set(gca,'XColor','none')
hold on
plot(x2)
hold off
nexttile
hold on
plot(x3)
hold off
Adriaan
  • 17,741
  • 7
  • 42
  • 75
Alina
  • 1
  • 2
  • 1
    Please don't delete the question after someone put in effort to answer it. Instead, click the gray checkmark to the left of the answer, to accept it. That tells people that your question has been answered satisfactorily, and gives credit to the person that put in effort to help you. – Cris Luengo Sep 01 '20 at 19:01

1 Answers1

2

As the documentation on tiledlayout() tells you:

title(t,'Size vs. Distance')
xlabel(t,'Distance (mm)')
ylabel(t,'Size (mm)')

generates spanning axis labels and titles. In your case ylabel(tlo,'Your Y label');


Two style notes:

  • if you're only plotting a single plot, there's no need to hold on;hold off every plot. Also hold off is only necessary if at some point you no longer want to hold the plot, i.e. when you want to overwrite its contents.

  • set(gca, __) has been superseded by OOP style syntax. Using t1 = nexttile; t1.XColor = 'none' makes for cleaner and supposedly faster code.

Adriaan
  • 17,741
  • 7
  • 42
  • 75