フィルターのクリア

How to use 'layout' in nexttile to make the legend appear in the sixth position in 6 tiled chart?

4 ビュー (過去 30 日間)
Wolfgang McCormack
Wolfgang McCormack 2021 年 5 月 28 日
回答済み: Milly 2024 年 1 月 10 日
Hi all,
if we have a 6 tiled chart. How do you use layout for legend to put the legend in the 6th tile?
Thanks
  1 件のコメント
Wolfgang McCormack
Wolfgang McCormack 2021 年 6 月 6 日
@Star Strider Hi, sorry for tagging you but you are super professional with MATLAB, so I thought you might know the answer to this one. I appreciate your time.

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

回答 (2 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 28 日
Hi,
Here is a realtively simple solution via an easy example:
A = randi([1, 5], 6);
p = bar(A);
legend(p(1,6),{'6-th tile'})
Good luck.
  1 件のコメント
Wolfgang McCormack
Wolfgang McCormack 2021 年 5 月 28 日
@Sulaymon Eshkabilov Hi, thanks but it's not doing what I wanted. It's showing the 6th one in the legend. I want the legend to appear in the 6th tile in a tiled chart which has 5 actual charts.

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


Milly
Milly 2024 年 1 月 10 日
To put the legend in the 6th tile:
lgd = legend(names); % assign legend to a variable
lgd.Layout.Tile = 6; % specify the 6th tile
If you are adding a 'flow' of tiles in a for loop and don't know what number of tiles you will have, use:
figure(1)
tiledlayout("flow")
for x = Array_to_loop_through
nexttile
(some plot code using x)
end
lgd = legend(names);
lgd.Layout.Tile = numel(Array_to_loop_through) + 1 ; % numel = number of elements

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by