Legend appears at wrong place using GUIDE
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Geoff Hayes
am 2 Jun. 2016
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 Kommentare
Walter Roberson
am 2 Jun. 2016
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.
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!