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

25 ビュー (過去 30 日間)
Zhe Dong
Zhe Dong 2024 年 1 月 5 日
コメント済み: Dyuman Joshi 2024 年 1 月 5 日
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!
Dyuman Joshi
Dyuman Joshi 2024 年 1 月 5 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by