![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1762239/image.png)
Change Figure Bottom Margin
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Gautam
il 29 Ago 2024
Modificato: Gautam
il 29 Ago 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 Commenti
Vedere anche
Categorie
Scopri di più su Subplots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!