Adding titles squashes one of my images in a TiledChartLayout (R2020a)

1 回表示 (過去 30 日間)
Matt J
Matt J 2021 年 4 月 30 日
コメント済み: Matt J 2021 年 5 月 4 日
I have a TiledChartLayout of 6 images that initially looks like this:
Then, however, I add titles to the upper 5 images and it squashes the lower image to a flat line, resulting in this:
I tried resizing the figure, to no avail. Why might this be happening and how do I prevent it?
  6 件のコメント
Matt J
Matt J 2021 年 4 月 30 日
Maybe pre-set the title of the axes?
Same result...
Matt J
Matt J 2021 年 4 月 30 日
Seems to work fine in R2021a:
h=openfig('testFig');
str='ABCDE';
ax=flip(findobj('Type','axes'));
for i=1:5, title(ax(i),str(i)); ax(i).FontSize=15; end
h.Position(4)=1.1*h.Position(4);
figure(h)

サインインしてコメントする。

採用された回答

Benjamin Kraus
Benjamin Kraus 2021 年 4 月 30 日
編集済み: Benjamin Kraus 2021 年 4 月 30 日
I opened the figure you created, and I see you have set the GridSize to [2756 3840].
TiledChartLayout is attempting to keep each of those axes the same height, so when you add a title to any axes in the second row it is going to make space for a title on all 2755 rows in between the axes.
A better approach is to leverage the south tile of the TiledChartLayout.
Generically:
t = tiledlayout('flow');
for i = 1:5
ax(i) = nexttile(t);
imagesc(ax(i),rand(100));
axis(ax(i),'off','square');
title(ax(i), char('@'+i));
ax(i).FontSize = 15;
end
ax(6) = axes(t);
imagesc(ax(6),linspace(0,1,256).*[1;1]);
colormap(t.Parent, gray);
ax(6).Layout.Tile = 'south';
pbaspect(ax(6),[20 1 1])
axis(ax(6),'off')
Or better yet, use the regular colorbar:
t = tiledlayout('flow');
for i = 1:5
ax(i) = nexttile(t);
imagesc(ax(i),rand(100));
axis(ax(i),'off','square');
title(ax(i), char('@'+i));
ax(i).FontSize = 15;
end
colormap(t.Parent, gray);
c = colorbar;
c.Layout.Tile = 'south';
  3 件のコメント
Benjamin Kraus
Benjamin Kraus 2021 年 5 月 4 日
@Matt J TiledChartLayout first shipped in R2019b, but there have been some bug fixes and improvements over the past few releases. One improvement (made in R2020b) is in how TileChartLayout handles axes with constrained plot box aspect ratios. The Colorbar gained the Layout property in R2020b as well.
Matt J
Matt J 2021 年 5 月 4 日
Then, is there any workaround that will let me constrain plot box aspect ratios in 2020a?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by