plotコマンドを使​わずに、新規figu​reに元のグラフをコ​ピーをする。

13 ビュー (過去 30 日間)
Mamoru Mabuchi
Mamoru Mabuchi 2020 年 6 月 25 日
回答済み: Akira Agata 2020 年 6 月 26 日
下の図のような、通常のグラフと、拡大のグラフを描画させたいです。
plotコマンドによる再描画ではなく、グラフをコピーすることはできますか?
-------------------------------
figure(1)
ax(1) = axes('Position',[0.1, 0.55 , 0.8182, 0.4091]);
ax(2) = axes('Position',[0.1, 0.1 , 0.8182, 0.4091]);
x1=0:0.1:10;
plot(ax(1),x1,sin(x1)) % グラフ1
plot(ax(2),x1,sin(3*x1)) % グラフ2
figure(2)
% plotコマンドを使わずに、グラフ2をfigure(2)内に描画したい
% plot(ax(2),x1,sin(3*x1)) % グラフ2
xlim([2 5])

採用された回答

Akira Agata
Akira Agata 2020 年 6 月 26 日
copyobj を使うのはいかがでしょうか?
たとえばご質問頂いた例では、以下のようになります。
figure
ax1 = axes('Position',[0.1, 0.55 , 0.8182, 0.4091]);
ax2 = axes('Position',[0.1, 0.1 , 0.8182, 0.4091]);
x1 = 0:0.1:10;
plot(ax1,x1,sin(x1)) % グラフ1
pHandle = plot(ax2,x1,sin(3*x1)); % グラフ2
figure
ax3 = axes;
copyobj(pHandle,ax3); % グラフ2のプロットハンドルをcopyして、ax3をParentとして割り当てる
xlim([2 5])

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2 次元および 3 次元プロット についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!