필터 지우기
필터 지우기

Three plots with tiledlayout

조회 수: 23 (최근 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 CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by