Add shared colorbar on some rows only

27 次查看(过去 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!

采纳的回答

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

更多回答(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