How can I combine saved .fig files as subplots in new figure - when they have been created using yyaxis?
15 views (last 30 days)
Show older comments
Hi, I am trying to combine the attached four figures into a single figure with 2x2 subplots. Using codes from related questions previously posted on the forum, I have come up with the following attempt:
% Load saved figures
f1=hgload('Pred_dens_full_h1.fig');
f2=hgload('Pred_dens_full_h6.fig');
f3=hgload('Pred_dens_full_h12.fig');
f4=hgload('Pred_dens_full_h24.fig');
% Prepare subplots
fig_name = 'Pred_dens_full';
figure('Name',fig_name)
h=gobjects(2*2,1); % preallocate for the axes handles
h(1)=subplot(2,2,1); title('h=1');
h(2)=subplot(2,2,2); title('h=6');
h(3)=subplot(2,2,3); title('h=12');
h(4)=subplot(2,2,4); title('h=24');
% Paste figures on the subplots
copyobj(allchild(get(f1,'CurrentAxes')),h(1));
copyobj(allchild(get(f2,'CurrentAxes')),h(2));
copyobj(allchild(get(f3,'CurrentAxes')),h(3));
copyobj(allchild(get(f4,'CurrentAxes')),h(4));
% Add legends
xlim(h,[0,70]);
While the code makes a new figure with 2x2 subplots, unfortunately the y-axis fails to take into account that the previously saved figures have been created with the yyaxis command. Is there any way that I can fix this?
Thank you for your time.
0 Comments
Answers (1)
Prabhanjan Mentla
on 1 Jan 2021
Hi,
However, you could achieve the same by converting them into png/jpg using matlab, subplot followed by imshow.
[X1,map1]=imread('Pred_dens_full_h1.png');
[X2,map2]=imread('Pred_dens_full_h6.png');
subplot(1,2,1);
imshow(X1,map1);
subplot(1,2,2);
imshow(X2,map2);
Hope this helps.
0 Comments
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!