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]);
0 个评论
回答(1 个)
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
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!