Subplot 'super' legend

29 次查看(过去 30 天)
Ziv Kassner
Ziv Kassner 2015-10-1
编辑: Adam Danz 2021-4-26
Is there any new function that allows you to create a legend for all subplots?

采纳的回答

Luffy
Luffy 2015-10-1
编辑:Luffy 2015-10-1
  2 个评论
Ziv Kassner
Ziv Kassner 2015-10-1
I was wondering whether there's a new way... thanks anyway
Adam Danz
Adam Danz 2021-4-26
Actually, Matlab does support a global legend in recent releases.
Another answer on that same page provides a demonstration.

请先登录,再进行评论。

更多回答(1 个)

Victor Castro di Filippo
编辑:Victor Castro di Filippo 2021-4-26
Hi. I find this post looking for the same. I found this and works fantastic. Almost 6 years and a pandemic later i hope this works for you. https://www.mathworks.com/matlabcentral/answers/387391-multiple-plots-with-same-legend#answer_309608
On this part you can put your list of string and thats it
legend('show')
  1 个评论
Adam Danz
Adam Danz 2021-4-26
编辑:Adam Danz 2021-4-26
This only shows object plotted on the current axes. For example, it doesn't work in this example below. However you can add a global legend by following one of the example in the other answer in the link you shared.
figure
subplot(211)
plot(rand(2,5))
subplot(212)
plot(rand(1,5))
legend('show')

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by