Tile spacing with modified aspect ratios
55 次查看(过去 30 天)
显示 更早的评论
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 个评论
Dolly More
2023-8-10
编辑:Dolly More
2023-8-10
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.
采纳的回答
Geetla Sindhu
2022-9-8
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
By using
p.Position(2)=0.2;
p.Position(3)=0.5;
p.Position(4)=0.7;
the following plot is obtained.
You can refer to the below documentation for further information:
2 个评论
Dolly More
2023-8-10
编辑:Dolly More
2023-8-10
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?
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!