Effacer les filtres
Effacer les filtres

How to combine two plots, each with multiple plots

1 vue (au cours des 30 derniers jours)
John Kim
John Kim le 19 Mar 2022
Commenté : Voss le 20 Mar 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.

Réponse acceptée

Voss
Voss le 19 Mar 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 commentaires
John Kim
John Kim le 20 Mar 2022
Thanks so much! Works like a charm!
Voss
Voss le 20 Mar 2022
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Objects dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by