How to place a global legend into an empty tile in a tiled layout?

조회 수: 24 (최근 30일)
I'm making a 7x2 tiled layout figure, but I only have 13 subplots, which means I have an empty tile, I wonder if there's a way that I can place my global legend into the empty tile, to save some space and make the figure neater. I'm using the latest version of Matlab (2023b), any thoughts or suggestions are highly appreciated!

채택된 답변

Dyuman Joshi
Dyuman Joshi 2024년 1월 5일
편집: Dyuman Joshi 2024년 1월 5일
Yes, you can place the legend in the empty tile by specifying the tile number.
Here's a demo -
%Plotting random data in the first 13 tiles
tiledlayout(7,2);
for k=1:13
nexttile
plot(sort(rand(10,1)), rand(10, 2))
end
%Define Legend
l = legend({'First line', 'Second line'});
%Changed the tile of the legend to the empty one which is 14 here
l.Layout.Tile = 14;
  댓글 수: 2
Zhe Dong
Zhe Dong 2024년 1월 5일
wow that is surprisingly easy! Many thanks for the prompt response!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by