Tile spacing with modified aspect ratios
30 views (last 30 days)
Show older comments
I am creating a 2 x 2 tiled plot in which each tile has a modified aspect ratio using the pbaspect command, where the modified aspect ratio (3 x 2 x 1) makes each tile plot somewhat less wide than the default setting. However when I set TileSpacing to 'compact', which is what I want to minimize the space between each tile, there is extra space in the middle between the two tiles on the left and the two tiles on the right hand side of the plot. Is there any way to make the TileSpacing command work with the modified aspect ratios? I have pasted in below a simplified version of the code for the plot.
f = figure();
f.WindowState = 'maximized';
asp1=3;
asp2=2;
asp3=1;
p=tiledlayout(2,2);
nexttile
plot(x1,y1);
pbaspect([asp1 asp2 asp3])
nexttile
plot(x2,y2);
pbaspect([asp1 asp2 asp3])
nexttile
hold on
box on
plot(x3,y3);
pbaspect([asp1 asp2 asp3])
nexttile
plot(x4,y4);
pbaspect([asp1 asp2 asp3])
p.TileSpacing = 'compact';
p.Padding = 'compact';
3 Comments
Dolly More
on 10 Aug 2023
Edited: Dolly More
on 10 Aug 2023
Did p.Position work for you? Its not working for me. I am getting Warning saying "Warning: Unable to set 'Position', 'InnerPosition', 'OuterPosition', or 'PositionConstraint' for objects in a TiledChartLayout "
I tired ltilespacing 'tight' and changed the aspect ratio of one column using pbaspect([1 1 1]) as I need to keep the aspect ratio equal for TS plot. But my plot still has extra white space and size of my squared tiles is also reducing. Can I just give tilespacing "none" for just one column of tiles in the tiledlayout? Please let me know if anything worked for you?
PS: I have attached screenshot of my plot for reference.
Accepted Answer
Geetla Sindhu
on 8 Sep 2022
Hello,
I understand that you are trying to remove the spaces between the tiles by maintaining the aspect ratios.
If you use pbaspect on the axes, this will distribute the axes (which means there is a lot of space in between them). In order to remove the spaces, you can adjust the tiled layout Position (this will keep the axes together, putting the space at one side).
Use p.Position property to adjust the spaces between the tiles.
For example, the plot obtained from the code which was used is shown below![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1119925/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1119925/image.png)
By using
p.Position(2)=0.2;
p.Position(3)=0.5;
p.Position(4)=0.7;
the following plot is obtained.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1119930/image.png)
You can refer to the below documentation for further information:
2 Comments
Dolly More
on 10 Aug 2023
Edited: Dolly More
on 10 Aug 2023
I tried using P.Position for changed aspect ratio tiles. It isn't working for me and I am getting a warning saying 'Unable to change the Position, innerposition and outerposition". Do you know why it might not be working for me?
Also, can I just give tilespacing "none" for just one column of tiles in the tiledlayout?
More Answers (0)
See Also
Categories
Find more on Two y-axis 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!