Add shared colorbar on some rows only
조회 수: 16 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Axes Appearance에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!