打印为 .eps 时,Matlab 提供光栅化图形而不是矢量图形

Matlab provides a rasterized figure instead of vector graphics when printing as .eps

当我尝试以 Matlab 格式打印 3d 图形(实际上只有这个图形)作为 .eps 格式时,它不提供矢量图形而是提供光栅化图形作为我的输出.

这个问题只存在于这个特定的数字上,其余的都很好(正如预期的那样)。

此问题在 2014b2015a2016b 中重复出现,因为这些是唯一可用的软件版本,我无法在其他版本上进行测试。此外,如果其他人遇到此类问题?

这是我第一次遇到这样的问题,因为直到现在我在图形打印(2d 和 3d)方面都没有遇到过任何问题。

请分享您的建议以解决此问题。

clc
clear all
close all

warning('off','all')
warning

%% print size def
width = 6;     % Width in inches
height = 4.9;    % Height in inches
alw = 1;    % AxesLineWidth
fsz = 12;      % Fontsize
lw = 1.5;      % LineWidth
msz = 8;       % MarkerSize
set(0,'defaultLineLineWidth',lw);   % set the default line width to lw
set(0,'defaultLineMarkerSize',msz); % set the default line marker size to msz
set(0,'defaultLineLineWidth',lw);   % set the default line width to lw
set(0,'defaultLineMarkerSize',msz); % set the default line marker size to msz
set(0,'DefaultAxesFontSize',fsz)
% Set the default Size for display
defpos = get(0,'defaultFigurePosition');
set(0,'defaultFigurePosition', [defpos(1) defpos(2) width*100, height*100]);

% Set the defaults for saving/printing to a file
set(0,'defaultFigureInvertHardcopy','on'); % This is the default anyway
set(0,'defaultFigurePaperUnits','inches'); % This is the default anyway
defsize = get(gcf, 'PaperSize');
left = (defsize(1)- width)/2;
bottom = (defsize(2)- height)/2;
defsize = [left, bottom, width, height];
set(0, 'defaultFigurePaperPosition', defsize);

%% loading the data
load('E_fw')
%norm of fw with mass
j=1;
for i=2:1:length(E_m1)
    if length(E_m1{i})>1
        e_m1{j}=E_m1{i}';
        L_m1(j)=length(E_nm1{i});
        j=j+1;
    end
end

%% plotting m1
t_m1=(0:1:max(L_m1)-1)/8000;
x_m1=1:1:length(L_m1);
for i=1:1:length(L_m1)
    B_m1(:,i)=[e_m1{i};ones(max(L_m1)-length(e_m1{i}),1)*inf];
end
[X_ss,Y_ss]=meshgrid(t_m1,x_m1);

g=figure
surf(X_ss,Y_ss,abs(B_m1'), 'LineStyle', 'none', 'FaceColor', 'interp'),grid minor
colormap(flipud(hot))
view([-1, -1, 7])%xaxis from 0 (neg, same for all)
camlight headlight
lighting gouraud
xlabel('op');
ylabel('dop');
zlabel('V');
box on
ax = gca;
ax.LineWidth = lw;
zlim([0 1.6])
xlim([0 0.3])
ylim([1 max(max(abs(Y_ss)))])
set(g,'Units','Inches');
pos = get(g,'Position');
set(g,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), 
pos(4)])
print('map_m1_3d', '-depsc', '-r0');

由于此问题仅针对这种特殊情况发生,我请求您使用 link 中提供的数据文件以及此 MWE。该问题也已报告给 Mathworks。

The necessary data file E_fw.mat is available in the g-drive link inside the data.zip

所有在这里指导我的人(以及将来可能遇到同样问题的人),我收到了 Mathworks 的回复,说它确实会自动切换到光栅化模式(他们没有解释如何)当某些违反了条件(正如@AndrasDeak 所解释的)。所以覆盖的方法是在 print 参数中使用 -painters 扩展,唯一的缺点是输出文件的大小以非线性方式膨胀,这明显取决于输出图形的复杂性。

我还应该说,当 -painters 扩展用于覆盖内部开关时,在我的例子中,我最终得到了大约 450 MB 的 .eps 大小,这实际上是巨大的出于文档目的,必须重复使用它们。