Borrar filtros
Borrar filtros

Three plots with tiledlayout

23 visualizaciones (últimos 30 días)
Mario C
Mario C el 26 de Jul. de 2022
Comentada: Mario C el 28 de Jul. de 2022
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

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 26 de Jul. de 2022
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 comentario
Mario C
Mario C el 28 de Jul. de 2022
Works like a charm!
Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by