Combining charts for comparison

21 ビュー (過去 30 日間)
Hai Nguyen
Hai Nguyen 2021 年 3 月 30 日
コメント済み: Hai Nguyen 2021 年 3 月 30 日
I want to combine 4 charts as per attached. The charts are extracted from running the attached code by changing K, C between 0 and 1. But the result shows 1 chart only. How to fix please?
Code to combine:
if true
fig = figure(10);
ax = axes(fig);
xlabel('\tau');
ylabel(' \Psi(0,\tau)');
title('Injection rate vs. K, C');
h1 = openfig('K0C0.fig','reuse');
h2 = openfig('K0C1.fig','reuse');
h3 = openfig('K1C0.fig','reuse');
h4 = openfig('K1C1.fig','reuse');
copyobj(h1.Children.Children,ax);
copyobj(h2.Children.Children,ax);
copyobj(h3.Children.Children,ax);
copyobj(h4.Children.Children,ax);
close(h1);
close(h2);
close(h3);
close(h4);
savefig('ratevsKC');
end
hold on
legend('K=0,C=0','K=0,C=1','K=1,C=0','K=1,C=1','location', 'southeast')
Combined result:
  2 件のコメント
Hai Nguyen
Hai Nguyen 2021 年 3 月 30 日
I tried. In my case it showed blank in the combined figure.

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

採用された回答

KSSV
KSSV 2021 年 3 月 30 日
if true
fig = figure(10);
ax = axes(fig);
xlabel('\tau');
ylabel(' \Psi(0,\tau)');
title('Injection rate vs. K, C');
h1 = openfig('K0C0.fig','reuse');
h2 = openfig('K0C1.fig','reuse');
h3 = openfig('K1C0.fig','reuse');
h4 = openfig('K1C1.fig','reuse');
% GEt x and y data from figure
x1 = zeros(length(h1.Children.Children),1) ;
y1 = zeros(length(h1.Children.Children),1) ;
for i = 1:length(h1.Children.Children)
x1(i) = h1.Children.Children(i).XData ;
y1(i) = h1.Children.Children(i).YData ;
end
close(h1);
x2 = zeros(length(h2.Children.Children),1) ;
y2 = zeros(length(h2.Children.Children),1) ;
for i = 1:length(h2.Children.Children)
x2(i) = h2.Children.Children(i).XData ;
y2(i) = h2.Children.Children(i).YData ;
end
close(h2);
x3 = zeros(length(h3.Children.Children),1) ;
y3 = zeros(length(h3.Children.Children),1) ;
for i = 1:length(h3.Children.Children)
x3(i) = h3.Children.Children(i).XData ;
y3(i) = h3.Children.Children(i).YData ;
end
close(h3);
x4 = zeros(length(h4.Children.Children),1) ;
y4 = zeros(length(h4.Children.Children),1) ;
for i = 1:length(h4.Children.Children)
x4(i) = h4.Children.Children(i).XData ;
y4(i) = h4.Children.Children(i).YData ;
end
close(h4);
figure
plot(x1,y1,'-*r',x2,y2,'-sk',x3,y3,'-ob',x4,y4,'-dc');
savefig('ratevsKC');
legend('K=0,C=0','K=0,C=1','K=1,C=0','K=1,C=1','location', 'southeast')
end
  1 件のコメント
Hai Nguyen
Hai Nguyen 2021 年 3 月 30 日
Thank you very much for the help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by