Borrar filtros
Borrar filtros

How to combine two plots, each with multiple plots

1 visualización (últimos 30 días)
John Kim
John Kim el 19 de Mzo. de 2022
Comentada: Voss el 20 de Mzo. de 2022
Hello, suppose I have time series plots, for example, sales growth and stock returns for nine industries.
I want to create a figure where Panel A would be 3 x 3 tiledlayout of sales growth for each of the nine industries, Panel B would be 3 x 3 tiledlayout of stock returns for each of the nine industries.
One way would be to create 6 x 3 tiledlayout, but I'm curious if there is a way for me to create these figures separately, and then reapply tiledlayout. For example, a pseudo-code I'd ideally want is something like:
CY = Sales_growth; % Sales_growth is a 9 x 1 cell, each with time series.
tiledlayout(3,3)
for cat = 1:NIndustry
nexttile
plot(CY{industry},'blue','LineWidth',2)
title(Industry_Name{cat}) % Industry_Name is a 9 x 1 cell, each with the name of the industry
end
Do something like "save figure as Panel A"
CY = Stock_returns; % Stock_returns is a 9 x 1 cell, each with time series.
tiledlayout(3,3)
for cat = 1:NIndustry
nexttile
plot(CY{industry},'blue','LineWidth',2)
title(Industry_Name{cat}) % Industry_Name is a 9 x 1 cell, each with the name of the industry
end
Do something like "save figure as Panel B"
At this point, do something like
tiledlayout(2,1)
nextile
Panel_A
title('Panel A: Sales Growth')
nexttile
Panel_B
title('Panel A: Stock Returns')
I would really really appreciate any and all advice, comments, and helps! Thanks so much for your time.

Respuesta aceptada

Voss
Voss el 19 de Mzo. de 2022
figure()
p1 = uipanel('Title','Sales Growth','Position',[0 0.5 1 0.5]);
t1 = tiledlayout(p1,3,3);
for i = 1:9
nexttile(t1);
plot(1:10);
end
p2 = uipanel('Title','Stock Returns','Position',[0 0 1 0.5]);
t2 = tiledlayout(p2,3,3);
for i = 1:9
nexttile(t2);
plot(1:10);
end
  2 comentarios
John Kim
John Kim el 20 de Mzo. de 2022
Thanks so much! Works like a charm!
Voss
Voss el 20 de Mzo. de 2022
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Objects en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by