Three plots with tiledlayout

9 ビュー (過去 30 日間)
Mario C
Mario C 2022 年 7 月 26 日
コメント済み: Mario C 2022 年 7 月 28 日
Hi all,
I have three charts that I want to combine in a single figure, and I would like to have the third plot to be centered in the second row.
The code belox can be used as an example. The function with z=3 appears right below z=1, as expected.
Is there a way for the third chart to be in the middle of the second row? I am not interested in making the third chart twice as large (i.e. not nexttile([1,2])), intead I would like to have z=3 with the same size asn z=1 and z=2 and centered.
Thank you beforehand!
Mario
clear;
clc;
close all;
syms x y z
figure
tiledlayout(2,2);
for z = [1 2 3]
nexttile
y = x^z;
fplot(x,y)
end

採用された回答

Cris LaPierre
Cris LaPierre 2022 年 7 月 26 日
One way to do this is to use the following syntax: nexttile(tilelocation,span)
Below, I create a 2x4 grid instead of 2x2. Then I can place the axes as needed to get the desired appearance. Here, the first plot is placed in the first row, and spans the first 2 columns. The second plot is placed in the first row, and spans the next 2 columns (3&4). The final plot is placed in location 6 (2nd row, 2nd spot) and also spans 2 columns (6&7).
syms x y
figure
tiledlayout(2,4);
nexttile([1,2])
y = x^1;
fplot(x,y)
nexttile([1,2])
y = x^2;
fplot(x,y)
nexttile(6,[1,2])
y = x^3;
fplot(x,y)
  1 件のコメント
Mario C
Mario C 2022 年 7 月 28 日
Works like a charm!
Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by