Splitting a horizontal legend across two lines

76 ビュー (過去 30 日間)
James
James 2023 年 7 月 17 日
編集済み: Voss 2023 年 7 月 17 日
I am not sure why this is such a difficult question to find an answer to, I have found similar questions here, but they are not relavent to my issue.
I am plotting a figure with 9 different datasets plotted for comparison. When I create a 'southoutside', 'horizontal' legend, I get a long legend bar on a single line. Instead, what I would like to do is span the legend over two lines, so dataset 1-5 on the upper line, and dataset 6-9 on the lower line. So I can't specify NumColumns; I need to specify the NumRows equivalent, or something akin to this:
legend({'Data 1', 'Data 2', 'Data 3', 'Data 4', 'Data 5'; 'Data 6', 'Data 7', 'Data 8', 'Data 9', ''}, ...
'Orientation', 'horizontal', 'Location', 'southoutside', 'Position', [Left, Bottom, Width, Height])

採用された回答

Voss
Voss 2023 年 7 月 17 日
編集済み: Voss 2023 年 7 月 17 日
plot(magic(9))
legend({'Data 1', 'Data 2', 'Data 3', 'Data 4', 'Data 5', 'Data 6', 'Data 7', 'Data 8', 'Data 9'}, ...
'Orientation', 'horizontal', 'Location', 'southoutside', 'NumColumns', 5)

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by