Combining charts for comparison

26 visualizaciones (últimos 30 días)
Hai Nguyen
Hai Nguyen el 30 de Mzo. de 2021
Comentada: Hai Nguyen el 30 de Mzo. de 2021
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 comentarios
Hai Nguyen
Hai Nguyen el 30 de Mzo. de 2021
I tried. In my case it showed blank in the combined figure.

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 30 de Mzo. de 2021
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 comentario
Hai Nguyen
Hai Nguyen el 30 de Mzo. de 2021
Thank you very much for the help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects 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