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!