Combine plot figures without losing legend

1 回表示 (過去 30 日間)
Yuktha Andie Ravinthiran
Yuktha Andie Ravinthiran 2022 年 2 月 18 日
コメント済み: Arif Hoq 2022 年 2 月 19 日
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

採用された回答

Arif Hoq
Arif Hoq 2022 年 2 月 19 日
編集済み: Arif Hoq 2022 年 2 月 19 日
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 件のコメント
Arif Hoq
Arif Hoq 2022 年 2 月 19 日
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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by