Add shared colorbar on some rows only

14 ビュー (過去 30 日間)
Eka Sulistyawan
Eka Sulistyawan 2023 年 8 月 20 日
コメント済み: Eka Sulistyawan 2023 年 8 月 20 日
Hi, I am using MATLAB R2021b (though, I got access to an earlier R2023~ version) and have to make the following layout using the tiledlayout,
Tile 1 to 8 were basically imagesc and Tile 9 to 12 were line plots. Is this possible?
Thanks in advance!


Dave B
Dave B 2023 年 8 月 20 日
You can accomplish this kind of layout by nesting tiledlayouts, and leveraging the TileSpan property.
Below, I create a 3 x 1 top layout, which will hold two child layouts. The first one will contain all the images, and because it holds twice as many rows I made it have a TileSpan that's twice that of the second child layout. To share the colorbar, I just placed it in the 'east' tile.
Note that even though the colorbar is 'shared' this only affects the way it's positioned, it is still linked to the color limits of one axes (the 8th tile in the example below). Consider setting all of the CLim of the 8 axes to be the same so that the scale correctly describes the set of axes it's visually linked to.
t0=tiledlayout(3,1); % A 'container' layout that holds two other layouts
t1=tiledlayout(t0,2,4); % The layout holding the images, and the colorbar
t1.Layout.TileSpan=[2 1]; % A TileSpan prevents the two rows from being squished to match the lower layout's height
for i = 1:8
t2.Layout.Tile = 3;
for i = 1:4
  1 件のコメント
Eka Sulistyawan
Eka Sulistyawan 2023 年 8 月 20 日
Oh wow, I never thought about nesting the tiledlayout.. thanks!


その他の回答 (0 件)


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



Community Treasure Hunt

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

Start Hunting!

Translated by