Why Matlab prints incorrect EPS figure

2 次查看(过去 30 天)
Two same figures are printed via following code, one .EPS and other .PDF.
.PDF is printed as desired (468 point X 468 point or exact 6.5" X 6.5").
.EPS is printed as (472 point x 472 point or 6.55555" X 6.5555").
I know through scaling in PostScript, .EPS can be fitted in the required dimension. But the problem is that MATLAB includes, incorrectly, some white space (about 4 point) on the right side of the .EPS figure. This doesn't happen when the .PDF is generated.
clear all
close all
X = 6.5; %# paper size
% Y = 6.5; %# paper size
Y = 6.5;
xMargin = 0; %# left/right margins from page borders
yMargin = 0; %# bottom/top margins from page borders
xSize = X - 2*xMargin; %# figure size on paper (widht & hieght)
ySize = Y - 2*yMargin; %# figure size on paper (widht & hieght)
%# create figure/axis
hFig = figure('Menubar','none');
plot([0 1 nan 0 1], [0 1 nan 1 0])
axis tight
% axis equal
hold on; x=0:0.001:1;y=x.^2;plot(x,y)
% theta=0:0.01:
tickValues = 0:0.05:1;
set(gca,'XTick',tickValues)
set(gca,'YTick',tickValues)
grid on
%
% set(gca, 'XTickLabel',[], 'YTickLabel',[], ...
% 'Units','normalized', 'Position',[0 0 1 1])
set(gca,'Units','normalized', 'Position',[0 0 1 1])
%# figure size displayed on screen (50% scaled, but same aspect ratio)
% Matlab 2013a rsults in correct print pdf when following two lines are
% enabled but Matlab2015a don't.
% set(hFig, 'Units','inches', 'Position',[0 0 xSize ySize]*.725)
% movegui(hFig, 'center')
%# figure size printed on paper
set(hFig, 'PaperUnits','inches')
% set(hFig, 'PaperUnits','points')
set(hFig, 'PaperSize',[X Y])
set(hFig, 'PaperPosition',[xMargin yMargin xSize ySize])
set(hFig, 'PaperOrientation','portrait')
%# Print to EPS and PDF
print -deps C:\out.eps
% print -dpsc C:\out.ps
% print -f1 -depsc2 C:\out.eps
print -dpdf C:\out.pdf

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by