Combine plot figures without losing legend
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Yuktha Andie Ravinthiran
am 18 Feb. 2022
Kommentiert: Arif Hoq
am 19 Feb. 2022
p2 = 'filename.xlsx'
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/899395/image.png)
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
0 Kommentare
Akzeptierte Antwort
Arif Hoq
am 19 Feb. 2022
Bearbeitet: Arif Hoq
am 19 Feb. 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 Kommentar
Arif Hoq
am 19 Feb. 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!