Why exporting a figure in pdf changes dimensions of subplots?
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello there. I'm working on my thesis paper. I run into a really annoying problem. I have to export a large number of figures in pdf. The figures are usually 2x2 subplots, each subplot containing square axis 2D maps superimposed by a contour plot.
I report here the code for a single map:
subplot(2,2,1);
% map
imagesc(f,f,real(X(:,:,1)));
% normal axis ydir
set(gca,'ydir','normal')
axis square
hold on;
contour(f,f,real(X(:,:,1)),4,'LineColor', [0 0 0]);
hold off;
set(gca,'xtick',(1.4:.1:1.8));
set(gca,'ytick',(1.4:.1:1.8));
axis([1.3 1.7 1.3 1.7]);
For reference, X is a complex 256x256x10 matrix, f is a 256x1 vector containing the x and y axis (that are equal).
When I make all four subplots repeating the code that I wrote previously and I export with the code reported after I get 4 slightly different sized subplots.
fig = gcf;
fig.PaperUnits = 'centimeters';
fig.PaperSize=[29.7 29.7];
fig.PaperPosition = [1 1 16 16];
print(fig,'ZNPC_DEC_B','-dpdf')
Now. It may seem crazy but I can't stand the difference in size between the generated plots. I need anyways to export my figure in pdf because I need to further elaborate it in a vector graphics software, so please don't propose a bitmap export.
A pdf is attached to the post, so you can get what's the problem.
Thanks in advice and have a nice summer!
댓글 수: 0
답변 (2개)
Iñigo Moreno
2020년 9월 28일
편집: Iñigo Moreno
2020년 9월 28일
With the newer versions of MATLAB you can use exportgraphics:
exportgraphics(fig,'ZNPC_DEC_B.pdf')
댓글 수: 0
Faiz Gouri
2017년 8월 17일
Did you try using the File Exchange contribution export_fig() which is especially suited to exporting figures for use in publications and presentations, because of the high quality and portability of media produced. It also includes a routine to append multiple files into a pdf
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!