Tile spacing with modified aspect ratios

57 次查看(过去 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 个评论
Eric Roden
Eric Roden 2022-9-5
Dear KSSV:
Thanks, yes, I had tried that, to no effect. It seems as if the tile spacing function does not function properly when the aspect ratio of the tiles is changed. Any other ideas anyone?
Best, Eric
Dolly More
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
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 个评论
Eric Roden
Eric Roden 2022-9-11
Dear Geetla:
Thank you this, this was very helpful. Just so I'll know, can you explain exactly what the three Positions correspond to? And also, what would be the value of p.Position (1)?
Kind regards, Eric
Dolly More
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 个)

类别

Help CenterFile Exchange 中查找有关 Two y-axis 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by