Legend appears at wrong place using GUIDE

1 次查看(过去 30 天)
I'm adding legends to my graphs in a programmatical GUI and I would like to control the size and position. When I use 'location', the legend shows up exactly where I told it to, but when I use 'position', it shows up in the bottom left corner of the figure/parent, no matter what values I fill in for position.
I added a simplified version of my work below.
f = figure;
tgroup = uitabgroup('Parent',f);
tab = uitab('Parent', tgroup);
ax1 = axes('Parent',tab);
plot(ax1,X,Y);
legend(ax1,'show',...
'parent','tab',...
'position',[0.5,0.5,0.1,0.02]);

回答(1 个)

Geoff Hayes
Geoff Hayes 2016-6-2
Eleonora - when I try to run your above code, I observe an error with legend due to the parent property. Is something new (post R2014)? Or, is it something that you have added and if so, what does it mean to you?
Note that if I remove this "property" I do see the legend appear in the bottom left corner as indicated by the position that you have set. But if I change it to say
[0.5,100.5,0.1,0.02]
then the legend moves accordingly.
  3 个评论
Walter Roberson
Walter Roberson 2016-6-2
The way legend() works is complicated and changed as of R2014b. You effectively can no longer set its Parent property. legend() formerly created an axes() whose properties could be controlled, but now it creates a legend object with a number of hidden (and sometimes redundant) properties.
Eleonora Rhijnsburger
So concluded, I can not set the legend where I want in 2015b?

请先登录,再进行评论。

类别

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