How to plot 2 figures with 2 subplots each ?

I need to plot 4 graphs and I need 2 of them in one figure and the other 2 graphs in the other figure.
Thanks for your help.

3 件のコメント

Sam Chak
Sam Chak 2022 年 6 月 1 日
Can you sketch out the figures so that we can have a good idea of what you want?
Semih Altun
Semih Altun 2022 年 6 月 1 日
if active.LIC0035==1
subplot(2,1,1)
yyaxis right
plot(Tag,LIC0035,'color',[0 64 0]/255,'Marker','none','LineStyle','-','MarkerIndices',[1:250:length(LIC2033)])
hold on
grid on
LegNamSub1(isub1) = {'LIC0035'}; %for legend
isub1 = isub1+1; %for legend
end
if active.FSI0029==1
subplot(2,1,2)
yyaxis right
plot(Tag,FSI0029,'color',[128 0 64]/255,'Marker','o','LineStyle','-','MarkerIndices',[1:250:length(LIC2033)])
hold on
grid on
LegNamSub2(isub2) = {'FSI0029'}; %for legend
isub2 = isub2+1; %for legend
end
This is an example. I defined the figures, the subplots of the figures and the axes in the beginning.
Now how can I tell Matlab, that I want the first graph (1st if clause) to be plotted in figure(1) subplot(2,1,1) and the second graph (2nd if clause) to be plotted in figure(2) subplot(2,1,2)?
Jan
Jan 2022 年 6 月 1 日
@Semih Altun: Did you read my answer? Exactly as shown there: Store the handles of the figures and provide the wnated handle as 1st input of the subplot command. This specifies the parent object the axes appears in.

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

回答 (1 件)

Jan
Jan 2022 年 6 月 1 日

0 投票

Fig1H = figure;
Ax1H = subplot(Fig1H, 1, 2, 1);
plot(Ax1H, rand(10));
Ax2H = subplot(Fig1H, 1, 2, 1);
plot(Ax2H, rand(10));
Fig2H = figure;
Ax3H = subplot(Fig2H, 1, 2, 1);
plot(Ax3H, rand(10));
Ax4H = subplot(Fig2H, 1, 2, 1);
plot(Ax4H, rand(10));

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

製品

リリース

R2021b

質問済み:

2022 年 6 月 1 日

コメント済み:

Jan
2022 年 6 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by