Combine plot figures without losing legend

1 visualización (últimos 30 días)
Yuktha Andie Ravinthiran
Yuktha Andie Ravinthiran el 18 de Feb. de 2022
Comentada: Arif Hoq el 19 de Feb. de 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

Respuesta aceptada

Arif Hoq
Arif Hoq el 19 de Feb. de 2022
Editada: Arif Hoq el 19 de Feb. de 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 comentario
Arif Hoq
Arif Hoq el 19 de Feb. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by