Change Figure Bottom Margin
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Gautam
2024 年 8 月 29 日
編集済み: Gautam
2024 年 8 月 29 日
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");
Hope this helps
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!