@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.
How to use 'layout' in nexttile to make the legend appear in the sixth position in 6 tiled chart?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (2개)
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.
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!