legend on subplot

62 次查看(过去 30 天)
SUDIP PODDAR
SUDIP PODDAR 2012-2-16
评论: Dan Po 2016-9-30
Hi all
I have an figure. I have draw numbers of subplot on that figure using iteration. Now i want to add legend(want to show iteration no as legened on each subplot) in each plot during iteration. How i will do that. I am using guide. plz help me. Thank you for your support.
  2 个评论
Sean de Wolski
Sean de Wolski 2012-2-16
You're using GUIDE and SUBPLOT()??
Why not just make the axes in GUIDE?
SUDIP PODDAR
SUDIP PODDAR 2012-2-16
I want to add legend dynamically on each subplot & the number of subplot is not predefined, it may be 10 or 20 or 25 like that.

请先登录,再进行评论。

回答(2 个)

ScottB
ScottB 2012-2-16
Each subplot is a unique axis. The legend command lets you specify the axis where the legend will be created:
"LEGEND(AX,...) puts a legend on the axes with handle AX."
So if you get the axis handles when you create the subplots you can then specify the legend for each subplot.
  2 个评论
SUDIP PODDAR
SUDIP PODDAR 2012-2-19
I cant understand. Plz specify briefly. Thanks for your reply
SUDIP PODDAR
SUDIP PODDAR 2012-2-19
i want to do the following. But not working. plz help
c=1:10
subplot(1,4,c), plot([1:100],'DisplayName','Fig 'c);
plz help me

请先登录,再进行评论。


Sean de Wolski
Sean de Wolski 2012-2-16
subplot(121);
peaks
legend('peaks');
subplot(122);
plot(1:10);
legend('1:10')
  1 个评论
Dan Po
Dan Po 2016-9-30
this actually works compared to other answers

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by