retrieve legend icon property from existing legend
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hi all,
in the documentation to legend (R2014b) it says
[h,icons,plots,str] = legend(___) %additionally returns the objects used to create the legend icons, the objects plotted in the graph, and an array of text strings.
for a new legend the icons object can be changed like
icon(i).MarkerSize=25;
if you know wich i you have to refer to. i want to alter the appearance of legend markers in an existing figure that i saved in a fig file. i do not want to plot it all anew. is there any more elegant way to retrieve an existing icons object than this one:
l=findall(gcf,'tag','legend');
[lh,ic,~,~]=legend(l.String,'Interpreter',l.Interpreter,'FontSize',l.FontSize,...
'TextColor',l.TextColor,'Units',l.Units,'UserData',l.UserData,'FontWeight',l.FontWeight,...
'Position',l.Position,'Color',l.Color,'Box',l.Box,'FontName',l.FontName,...
'Location',l.Location,'LineWidth',l.LineWidth); % transfer all properties from existing legend
delete(l)
i=findall(ic,'Type','Line'); % reduce to lines
for m=1:length(i) % change properties
i(m).MarkerSize=25;
end
thanks, Fabian
2 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!