Custom subplot of saved .fig images

1 次查看(过去 30 天)
Hello everyone. I have 8 .fig files that I want to plot in one new subplot (4X2). I did come across this solution but I want to make the new subplot with customized axes such that maximum screen space is used in mkaing the new figures. For this I use the tight subplot script. I already did try manipulating the code (attached) in the above webpage but it is not working. Following issues arise:-
  • The new subplot is not taking the custom axes into account, it simply plots each .fig in a normal new subplot and ends up wasting lots of page space.
  • None of the axis modifying commands work (caxis, axis equal, axis off, colormap). So every plot in the subplot is basically just the original plot but scaled down in physical size.
I do realize that the way I have modified the code mostly doesn't take the custom axes of tight_subplot into account at all. Can anyone please help me out here? I will be really really grateful :)
h1 = openfig('R1.5A15.fig'); % open figure
ax1 = gca; % get handle to axes of figure
h2 = openfig('R1.5A30.fig');
ax2 = gca;
h3 = openfig('R1.5A45.fig');
ax3 = gca;
h4 = openfig('R2A15.fig');
ax4 = gca;
h5 = openfig('R2A30.fig');
ax5 = gca;
h6 = openfig('R2A45.fig');
ax6 = gca;
h7 = openfig('R2.5A30.fig');
ax7 = gca;
h8 = openfig('R2.5A45.fig');
ax8 = gca;
h3 = figure; %create new figure
s1 = subplot(4,2,1); %create and get handle to the subplot axes
s2 = subplot(4,2,2);
s3 = subplot(4,2,3);
s4 = subplot(4,2,4);
s5 = subplot(4,2,5);
s6 = subplot(4,2,6);
s7 = subplot(4,2,7);
s8 = subplot(4,2,8);
fig1 = get(ax1,'children'); %get handle to all the children in the figure
fig2 = get(ax2,'children');
fig3 = get(ax3,'children');
fig4 = get(ax4,'children');
fig5 = get(ax5,'children');
fig6 = get(ax6,'children');
fig7 = get(ax7,'children');
fig8 = get(ax8,'children');
[ha, pos] = tight_subplot(4,2,[0.01 0.08], 0.01, 0.01);
[bnw]=buildcmap('wk');
axes(ha(1))
copyobj(fig1,s1); %copy children to new parent axes i.e. the subplot axes
caxis([0 0.35]);
set(gcf,'units','normalized','outerposition',[0 0 1 1],'color',[0.93 0.93 0.93]);
set(gca,'FontSize', 30,'color',[0 0 0]);
colormap jet
title('R1.5A15')
axis equal
axis off
axes(ha(2))
copyobj(fig2,s2);
caxis([0 0.35]);
set(gcf,'units','normalized','outerposition',[0 0 1 1],'color',[0.93 0.93 0.93]);
set(gca,'FontSize', 30,'color',[0 0 0]);
colormap(bnw)
title('R1.5A30')
axis equal
axis off
axes(ha(3))
copyobj(fig3,s3);
caxis([0 0.35]);
set(gcf,'units','normalized','outerposition',[0 0 1 1],'color',[0.93 0.93 0.93]);
set(gca,'FontSize', 30,'color',[0 0 0]);
colormap(bnw)
title('R1.5A45')
axis equal
axis off
axes(ha(4))
copyobj(fig4,s4);
caxis([0 0.35]);
set(gcf,'units','normalized','outerposition',[0 0 1 1],'color',[0.93 0.93 0.93]);
set(gca,'FontSize', 30,'color',[0 0 0]);
colormap(bnw)
title('R2A15')
axis equal
axis off
axes(ha(5))
copyobj(fig5,s5);
caxis([0 0.35]);
set(gcf,'units','normalized','outerposition',[0 0 1 1],'color',[0.93 0.93 0.93]);
set(gca,'FontSize', 30,'color',[0 0 0]);
colormap(bnw)
title('R2A30')
axis equal
axis off
axes(ha(6))
copyobj(fig6,s6);
caxis([0 0.35]);
set(gcf,'units','normalized','outerposition',[0 0 1 1],'color',[0.93 0.93 0.93]);
set(gca,'FontSize', 30,'color',[0 0 0]);
colormap(bnw)
title('R2A45')
axis equal
axis off
axes(ha(7))
copyobj(fig7,s7);
caxis([0 0.35]);
set(gcf,'units','normalized','outerposition',[0 0 1 1],'color',[0.93 0.93 0.93]);
set(gca,'FontSize', 30,'color',[0 0 0]);
colormap(bnw)
title('R2.5A30')
axis equal
axis off
axes(ha(8))
copyobj(fig8,s8);
caxis([0 0.35]);
set(gcf,'units','normalized','outerposition',[0 0 1 1],'color',[0.93 0.93 0.93]);
set(gca,'FontSize', 30,'color',[0 0 0]);
colormap(bnw)
title('R2.5A45')
axis equal
axis off
hp4 = pos{7};
c = colorbar('Position', [hp4(1)+hp4(3)+0.05 hp4(2)+0.03 0.01 hp4(2)+hp4(3)*1.95]);
c.TickLabelInterpreter = 'latex';
set(gca,'fontsize',30)

回答(0 个)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by