Setting the size of a tile when loading pre-created matlab figures
12 views (last 30 days)
Show older comments
Douwe Horsthuis
on 24 Oct 2022
Edited: Nirupama Nagarathinam
on 2 Nov 2022
Is it possible to set the size of a tile if you are working with pre-created matlab figures that you need to load?
As answered here, one can load the figures and add them to a new subplot. And as usual you can set the size of the subplot for example like this: s6 = subplot(3,3,[7:9]);
Is this also possible for tiles?
The suggested code for working with tiles from the previously mentioned question:
openfig('fig1.fig');
ax1=gca;
openfig('fig2.fig')
ax2=gca;
figure;
tcl=tiledlayout(1,2);
ax1.Parent=tcl;
ax1.Layout.Tile=1;
ax2.Parent=tcl;
ax2.Layout.Tile=2;
Since this does not use the nexttile function, I wouldn't know where to say how big the tiles should be.
Thank you for your time!
0 Comments
Accepted Answer
Nirupama Nagarathinam
on 28 Oct 2022
Edited: Nirupama Nagarathinam
on 2 Nov 2022
Yes, it is possible to set the size of tile with "TileSpan" property like that of "subplot" without using "nexttile".
Refer to this modified code:
openfig('fig1.fig');
ax1=gca;
openfig('fig2.fig')
ax2=gca;
figure;
tcl=tiledlayout(2,2); % 2 by 2 tile layout, so 4 tiles available
ax1.Parent=tcl;
ax1.Layout.Tile=1; % placing fig1 in the first tile
% For the figure to span multiple tiles, specify the "TileSpan" property as a two-element vector.
% The first element specifies the number of rows and the second element specifies the number of columns the figure should span.
ax1.Layout.TileSpan=[1 2]; % This code spans fig1 across one row and two columns of tiles starting from tile 1. So it occupies tiles 1 and 2.
ax2.Parent=tcl;
ax2.Layout.Tile=3; % placing fig2 in the third tile
ax2.Layout.TileSpan=[1 2]; % This code spans fig2 across one row and two columns of tiles starting from tile 3. So it occupies tiles 3 and 4.
I have verified the above code in R2019b MATLAB. Though "TileSpan" property was incorporated in the R2019b MATLAB release, it was not mentioned in the R2019b documentation. Hence, refer to this latest documentation link for more details.
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!