Display Shared Legend in Tiled Chart Layout - Example replication error message

7 ビュー (過去 30 日間)
Ben Morgan
Ben Morgan 2020 年 10 月 18 日
コメント済み: Aaron Kaw 2021 年 12 月 16 日
I've just discovered the existence of tiledlayouts as an alternative to subplots and have been trying to recreate the "Display Shared Legend in Tiled Chart Layout" example on the legend documentation page here: https://uk.mathworks.com/help/matlab/ref/legend.html
tiledlayout(2,2);
nexttile
plot(rand(5))
nexttile
plot(rand(5))
nexttile
plot(rand(5))
lgd = legend;
lgd.Layout.Tile = 4;
It runs fine if I use the online "Try This Example" button, but when copied exactly into Matlab on my desktop (v2020a), I get the following error message:
Error in DataAnalysis (line 117)
lgd.Layout.Tile = 4;
Unrecognized method, property, or field 'Layout' for class 'matlab.graphics.illustration.Legend'.
This is infurianting as I understand what the error is telling me, but don't know why it's happening when I can see the layout property exists in the documentation here: https://uk.mathworks.com/help/matlab/ref/matlab.graphics.illustration.legend-properties.html
Would massively appreciate it if someone with better knowledge could explain this to me please. Is this a version issue or a package I'm missing?

回答 (1 件)

Ben Morgan
Ben Morgan 2020 年 10 月 18 日
Nevermind, it's something that was added in 2020b.
  2 件のコメント
Yiliang Wang
Yiliang Wang 2021 年 8 月 16 日
right, it is only for 2020b.
Aaron Kaw
Aaron Kaw 2021 年 12 月 16 日
When you say "only," do you mean that it's not in 2021a onwards?

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by