フィルターのクリア

How to plot four scatter diagram on a single page?

1 回表示 (過去 30 日間)
gauri
gauri 2024 年 4 月 26 日
コメント済み: Adam Danz 2024 年 4 月 26 日
I am generating four plots one by one using loop in matlab code. I want to plot all four figures on a single page in 2x2 matrix. Please suggest me how to do it.
Gauri

回答 (1 件)

sai charan sampara
sai charan sampara 2024 年 4 月 26 日
Hello,
You can use the "tiledlayout" feature or "subplots" feature in MATLAB. It can be done as follows:
x = linspace(0,30);
y1 = sin(x/2);
y2 = sin(x/3);
y3 = sin(x/4);
y4 = sin(x/8);
% Using tiled layout
tiledlayout(2,2);
nexttile
scatter(x,y1)
nexttile
scatter(x,y2)
nexttile
scatter(x,y3)
nexttile
scatter(x,y4)
% Using subplot
subplot(2,2,1)
scatter(x,y1)
subplot(2,2,2)
scatter(x,y2)
subplot(2,2,3)
scatter(x,y3)
subplot(2,2,4)
scatter(x,y4)
You can refer to the following documentation for more information:
  1 件のコメント
Adam Danz
Adam Danz 2024 年 4 月 26 日
I recommend using tiledlayout rather than subplot, unless you're using a release older than R2019b.

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

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by