How to create tiledlayout grid in vertical order
Afficher commentaires plus anciens
Hello,
How to create tiledlayout grid in vertical order?
Let's say I want to create a tiledlayout(3,2), matlab default order is
1 2
3 4
5 6
But I want the lay out to be:
1 4
2 5
3 6
How do I do that?
Thanks,
Ping
Réponse acceptée
Plus de réponses (2)
Set up variables:
n_rows = 3;
n_cols = 2;
n = n_rows*n_cols;
data = (1:n)+zeros(10,1);
Default tiledlayout order, for reference:
figure
tiledlayout(n_rows,n_cols)
for ii = 1:n
nexttile()
plot(data(:,ii))
title(sprintf('%d',ii));
xlim([1 10])
ylim([0 n+1])
end
Reordering the layout:
idx = reshape(1:n,n_cols,[]).'
figure
tiledlayout(n_rows,n_cols)
for ii = 1:n
nexttile(idx(ii))
plot(data(:,ii))
title(sprintf('%d',ii));
xlim([1 10])
ylim([0 n+1])
end
The tiles are always numbered by row, column, but you can plot into the tiles in whatever order you want by specifying the tile (using Matlab's ordering).
tiledlayout(3,2)
nexttile
title 'First plot'
nexttile(3)
title 'Second plot'
nexttile(5)
title 'Third plot'
nexttile(2)
title 'Fourth plot'
nexttile(4)
title 'Fifth plot'
nexttile(6)
title 'Sixth plot'
Catégories
En savoir plus sur Axes Appearance dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



