Three plots with tiledlayout
조회 수: 23 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!