How to set the parent of the subplot in a neat way?

34 ビュー (過去 30 日間)
qilin guo
qilin guo 2022 年 9 月 19 日
コメント済み: qilin guo 2022 年 9 月 19 日
I know my question could sound strange at the first glance. Here I would like explain my question in more details. My MATLAB code goes as follows.
x = linspace(0, 2*pi, 11);
fig1 = figure('Name', 'A');
fig2 = figure('Name', 'B');
ax = subplot(1,2,1);
plot(x, sin(x.^2));
I have two figures, named A and B. The parent of ax will be fig2 by default. The question is that how to set the parent of ax to be fig1 rather than fig2 explicitly when I create ax? I know I could change the parent of ax after I create using ax.Parent = fig1, i.e.,
x = linspace(0, 2*pi, 11);
fig1 = figure('Name', 'A');
fig2 = figure('Name', 'B');
ax = subplot(1,2,1);
plot(x, sin(x.^2));
ax.Parent = fig1;
Thank you!

採用された回答

Bruno Luong
Bruno Luong 2022 年 9 月 19 日
ax = subplot(1,2,2,'Parent',fig1)
  1 件のコメント
qilin guo
qilin guo 2022 年 9 月 19 日
Beautiful! Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by