Combine plot figures without losing legend

1 vue (au cours des 30 derniers jours)
Yuktha Andie Ravinthiran
Yuktha Andie Ravinthiran le 18 Fév 2022
Commenté : Arif Hoq le 19 Fév 2022
p2 = 'filename.xlsx'
tiledlayout(2,2);
set(groot,'defaultLineLineWidth',1)
figure(1)
hold on
ex = xlsread(p2,'emission','E2:E37');
ey = xlsread(p2,'emission','C2:C361');
echunks = reshape(ey,[36,10])'
colors = jet(10);
grid on
for i = 1:10
plot(ex,rescale(echunks(i,:)), "color", colors(i,:))
end
title('Emission spectrum of QDs with surfactant')
xlabel('Wavelength /nm ')
ylabel('Emission(Normalized)')
legend('1','2','3','4','5','6','7','8','9','10')
hold off
I don't want to change anything about these figures individually
Just want to export them both in one figure

Réponse acceptée

Arif Hoq
Arif Hoq le 19 Fév 2022
Modifié(e) : Arif Hoq le 19 Fév 2022
you can use subplot. i dont have your data. here is a demo example.
figure(2)
subplot(2,1,1);
x = linspace(0,10);
y1 = sin(x);
y2 = cos(x);
plot(x,y1,x,y2)
legend('sin(x)','cos(x)')
title('plot of sin(x) & cos(x)')
xlabel('Time')
ylabel('sin(x) & cos(x)')
subplot(2,1,2);
y3 = sin(5*x);
y4 = cos(5*x);
plot(x,y3,x,y4)
legend('sin(5*x)','cos(5*x)')
title('plot of sin(5*x) & cos(5*x)')
xlabel('Time')
ylabel('sin(5*x) & cos(5*x)')
  1 commentaire
Arif Hoq
Arif Hoq le 19 Fév 2022
try this for loop. adjust your x and y axes data.
figure(2) ;
for i = 1:10
subplot(2, 1, 1) ;
plot(ex,rescale(echunks(i,:)), "color", colors(i,:))
title('Emission spectrum of QDs with surfactant')
xlabel('Wavelength /nm ')
ylabel('Emission(Normalized)')
legend('1','2','3','4','5','6','7','8','9','10')
end
figure(2) ;
for i = 1:10
subplot(2, 1, 2) ;
plot(ex,rescale(echunks(i,:)), "color", colors(i,:))
title('Absorbtion spectrum of QDs without surfactant')
xlabel('Wavelength /nm ')
ylabel('Absorbance')
legend('1','2','3','4','5','6','7','8','9','10')
end

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by