필터 지우기
필터 지우기

Add shared colorbar on some rows only

조회 수: 16 (최근 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.Tile=1;
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
nexttile(t1)
imagesc(peaks)
end
c=colorbar;
c.Layout.Tile='east';
t2=tiledlayout(t0,1,4);
t2.Layout.Tile = 3;
for i = 1:4
nexttile(t2)
plot(magic(5))
end
  댓글 수: 1
Eka Sulistyawan
Eka Sulistyawan 2023년 8월 20일
Oh wow, I never thought about nesting the tiledlayout.. thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axes Appearance에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by