How to make size of legend window on a figure window as small as we desire?????
38 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sadiq Akbar
el 1 de Jul. de 2022
Comentada: Sadiq Akbar
el 4 de Jul. de 2022
I have drawn my plot having a legend window on it. The legend is coming over the graph lines. I want to make size of the legend window as small as I want so that the graph is completely visible. How to do it? My figure is attached here.
1 comentario
Simon Chan
el 1 de Jul. de 2022
How about putting the legend outiside by setting the legend location?
Respuesta aceptada
Chunru
el 1 de Jul. de 2022
Editada: Chunru
el 1 de Jul. de 2022
openfig("fitness2snAll.fig");
figure
openfig("fitness2snAll.fig");
h = legend
% Try to adjust the position of the legend
% But the pos may be modified by MATLAB
pos = h.Position;
pos(1:2) = [0.5 0.35];
pos(3:4) = 0.5*pos(3:4)
h.Position = pos
figure
openfig("fitness2snAll.fig");
h = legend
h.Location = 'southoutside';
h.NumColumns = 3;
3 comentarios
Chunru
el 4 de Jul. de 2022
Matlab2016b may not have the NumColumns property.
When you specify the Position property too small, MATLAB may automatically adjust the size. One way to make the legend smaller is to change the font size as shown below.
Displayce the position is to find the best position for legend to avoid the overlapping with other part of the figure.
figure
openfig("fitness2snAll.fig");
h = legend
h.FontSize = 5; % adjust this to meet your need
pos = h.Position;
pos(1:2) = [0.45 0.35]; % displacement
pos(3:4) = pos(3:4) % size (if too small, matlab will adjust it)
h.Position = pos
Más 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!