0

I want to save 3 figures with image dimension 227×227.

  1. Heatmap1
  2. Heatmap1
  3. Subplots of heatmap1 and heatmap1

How must I edit my code on MATLAB ?

n2E = rand(10); % for example
n2 = rand(10 );

% Heatmap1
subplot(2,1,1 )
heata=heatmap(n2E );

%Heatmap2
subplot(2,1,2 )
heatp=heatmap(n2 );


%subplot of heatmaps
ha=get(gcf,'children ');
set(ha(1),'position',[.1 .1 .8 .4 ])
set(ha(2),'position',[.1 .5 .8 .5 ])

exportgraphics(gcf, 'figure.jpg ');
exportgraphics(ha(1), 'subplot1.jpg ');
exportgraphics(ha(2), 'subplot2.jpg');
Emm
  • 71
  • 8

1 Answers1

1

Try exportgraphics(ha(1),'subplot1.jpg','Resolution',227) You should also be able to pass the resolution to gcf using

set(gcf, 'PaperUnits', 'pixels');
x_width=227;
y_width=227;
set(gcf, 'PaperPosition', [0 0 x_width y_width]);
saveas(gcf,'subplot1.jpg');