How to extract one plot from multiple plots?
16 ビュー (過去 30 日間)
古いコメントを表示
回答 (1 件)
Tommy
2020 年 7 月 8 日
Assuming you have the figure handle, how about something like this?
% setup
f = figure;
for idx = 1:8
ax = subplot(4,2,idx);
plot(ax, rand(5));
end
clear idx ax
% copy, using only f
N = 2; % number of subplot to copy
f2 = figure;
referenceAx = axes(f2, 'Visible', 'off'); % to steal the Position from
newAx = copyobj(f.Children(end+1-N), f2);
newAx.Position = referenceAx.Position;
delete(referenceAx)
Maybe creating the invisible temporary axes is unnecessary, just seemed like an easy way to get the default size. Of course you don't have to reposition the axes at all if you don't want. Or an alternative would be to copy each child of axes #2 to the new set of axes.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!