Why exporting a figure in pdf changes dimensions of subplots?

8 次查看(过去 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!

回答(2 个)

Iñigo Moreno
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')

Faiz Gouri
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

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by