how to merge two figures

13 views (last 30 days)
mallela ankamma rao
mallela ankamma rao on 9 May 2022
Edited: Pavl M. on 26 Nov 2024 at 20:37
Good morning sir
i have attached two figures.i requesting you please help me how to merge two figures

Answers (3)

Stephan
Stephan on 9 May 2022
Have a look at: yyaxis
  2 Comments
mallela ankamma rao
mallela ankamma rao on 9 May 2022
please give me code sir
Pavl M.
Pavl M. on 26 Nov 2024 at 20:04
Edited: Pavl M. on 26 Nov 2024 at 20:37
How to license codes?
Better than Creative Commons?
Have you already embedded codes in the .fig files?
clc
clear all
close all
f1 = openfig('https://uk.mathworks.com/matlabcentral/answers/uploaded_files/991995/figure(1).fig','invisible')
f1 =
Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [403 246 560 420] Units: 'pixels' Use GET to show all properties
f2 = openfig('https://uk.mathworks.com/matlabcentral/answers/uploaded_files/992000/figure(2).fig','invisible')
f2 =
Figure (2) with properties: Number: 2 Name: '' Color: [1 1 1] Position: [403 246 560 420] Units: 'pixels' Use GET to show all properties
o1=findobj(f1,'Type','line');
x_f1=get(o1,'xdata');
y_f1=get(o1,'ydata');
o2=findobj(f2,'Type','line');
x_f2=get(o2,'xdata');
y_f2=get(o2,'ydata');
figure
yyaxis left
plot(x_f1,y_f1)
hold on
yyaxis right
plot(x_f2,y_f2)
hold off
title('Combined figures')
%Constructed by
%https://independent.academia.edu/PMazniker
%+380990535261, https://join.skype.com/invite/oXnJhbgys7oW
%https://diag.net/u/u6r3ondjie0w0l8138bafm095b
%https://github.com/goodengineer
%https://orcid.org/0000-0001-8184-8166
%https://willwork781147312.wordpress.com/portfolio/cp/
%https://www.youtube.com/channel/UCC__7jMOAHak0MVkUFtmO-w
%https://nanohub.org/members/130066
%https://pangian.com/user/hiretoserve/
%https://substack.com/profile/191772642-paul-m

Sign in to comment.


mallela ankamma rao
mallela ankamma rao on 9 May 2022
i have attached two figures

Pavl M.
Pavl M. on 26 Nov 2024 at 20:15
Edited: Pavl M. on 26 Nov 2024 at 20:35
How to license codes?
My codeworks programme are on Specific ECommerce License.
Have you already embedded codes in the .fig files?
clc
clear all
close all
%Since there are a few plots in figure with y axis "Infected", need
%to extract all children from it (object oriented, standard GUI feature
%like in Qt framework, using the class getters...doable...just need
%more time and investment to finish the yet commented codes.
open https://uk.mathworks.com/matlabcentral/answers/uploaded_files/992000/figure(1).fig;
fig = get(groot, 'CurrentFigure' )
fig =
Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [403 246 560 420] Units: 'pixels' Use GET to show all properties
hFigAxes = get(fig,'Children')
hFigAxes =
Axes with properties: XLim: [0 200] YLim: [0 3000000] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Use GET to show all properties
h1Plot = get(hFigAxes,'Children')
h1Plot =
2x1 graphics array: Line Scatter
x1Data = get(h1Plot,'XData')
x1Data = 2x1 cell array
{[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 ... ] (1x200 double)} {[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 ... ] (1x200 double)}
y1Data = get(h1Plot,'YData')
y1Data = 2x1 cell array
{[ 10000 9.1530e+03 8.5514e+03 8.1308e+03 7.8473e+03 7.6694e+03 7.5741e+03 7.5444e+03 7.5671e+03 7.6326e+03 7.7332e+03 7.8632e+03 8.0181e+03 8.1946e+03 ... ] (1x200 double)} {[1 1 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 5 6 28 30 31 34 39 48 63 71 81 91 102 112 126 146 171 198 256 334 403 497 571 657 730 883 ... ] (1x200 double)}
close(fig)
f2 = openfig('https://fr.mathworks.com/matlabcentral/answers/uploaded_files/991995/figure(2).fig','invisible')
f2 =
Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [403 246 560 420] Units: 'pixels' Use GET to show all properties
o2=findobj(f2,'Type','line');
x_f2=get(o2,'xdata');
y_f2=get(o2,'ydata');
figure
yyaxis left
plot(x1Data{1},y1Data{1})
hold on
plot(x1Data{2},y1Data{2})
hold on
yyaxis right
plot(x_f2,y_f2)
hold off
title('Combined Figures')
%Constructed by
%https://independent.academia.edu/PMazniker
%+380990535261, https://join.skype.com/invite/oXnJhbgys7oW
%https://diag.net/u/u6r3ondjie0w0l8138bafm095b
%https://github.com/goodengineer
%https://orcid.org/0000-0001-8184-8166
%https://willwork781147312.wordpress.com/portfolio/cp/
%https://www.youtube.com/channel/UCC__7jMOAHak0MVkUFtmO-w
%https://nanohub.org/members/130066
%https://pangian.com/user/hiretoserve/
%https://substack.com/profile/191772642-paul-m

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!