![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762239/image.png)
Change Figure Bottom Margin
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dear all,
I would like to generate a 2x3 subplot and display the legend below the figure:
%
figure
for i = 1:6
h_subplot = subplot(2,3,i);
plot(randn(10,2))
if i==5
h_legend = legend({'Data 1', 'Data 2'});
sp=get(h_subplot,'position');
set(h_legend,'position',[sp(1),sp(2)-.15,sp(3),.1]);
end
end
How can I extend the bottom margin, without resizing the subplots, such that the entire legend is shown?
Thanks, Peter
0 comentarios
Respuestas (1)
Gautam
el 29 de Ag. de 2024
Editada: Gautam
el 29 de Ag. de 2024
Hello Peter,
One easy way to extend the bottom margin of the figure without resizing the subplots is by adding another row to the subplots and setting the “Visibility” property of its axis to “off”
set(subplot(3,3,[7 8 9]), "Visible", "off");
The code below follows this to generate the corresponding output:
f=figure;
for i = 1:6
h_subplot = subplot(3,3,i);
plot(randn(10,2))
if i==5
h_legend = legend({'Data 1', 'Data 2'});
sp=get(h_subplot,'position');
set(h_legend,'position',[sp(1),sp(2)-.15,sp(3),.1]);
end
end
set(subplot(3,3,[7 8 9]), "Visible", "off");
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762239/image.png)
Hope this helps
0 comentarios
Ver también
Categorías
Más información sobre Subplots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!