How can I combine saved .fig files as subplots in new figure - when they have been created using yyaxis?
14 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Prabhanjan Mentla
2021-1-1
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!