Matlab在打印为.eps格式时提供了光栅化的图像而不是矢量图形。

3
当我尝试将一个3D图形(实际上只有这个图形)在Matlab中以.eps格式打印时,它并没有提供矢量图形,而是提供了一个栅格化的图像作为输出。
这个问题只出现在这个特定的图形中,其他图形都很好(如预期所示)。
这个问题在2014b、2015a和2016b中都有复制,因为这些是唯一可用的软件版本,我无法测试其他版本。此外,是否有人遇到过这种问题?
这是我第一次遇到这样的问题,因为直到现在我从未在图形打印方面遇到任何问题(包括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');

由于问题仅出现在此特定情况下,我建议您使用链接中提供的数据文件以及此 MWE。该问题也已向 Mathworks 报告。

必要的数据文件E_fw.mat可在链接中的data.zip内的 g-drive 链接中获得


3
请提供一个 [MCVE],即在您的帖子中以数据的形式提供所有信息,而不是将我们引导至其他网站。同时,尝试使用 Yair Altman 的 export_fig 工具。 - Sardar Usama
@SardarUsama 我宁愿提供那个,但我不确定如何在这里上传一个数据文件.mat,因为我使用一些数据文件来创建图形,在这种特定情况下问题是反复出现的。无论如何,我现在会发布MWE,请指导我如何发布必要的数据文件。 - Raaja_is_at_topanswers.xyz
1
你是否也读过/尝试过Sardar的建议,使用export_fig?或者我一直使用的内置saveassaveas(g,'outname.eps','epsc')。虽然我认为MATLAB可能会根据某些启发式方法切换到光栅化,但是我曾经意外地生成过表面图的矢量化150MB eps文件而没有任何问题,所以如果这是情况的话,我会感到惊讶。 - Andras Deak -- Слава Україні
对于所有指引我到这里(以及将来可能遇到相同问题的人),我收到了Mathworks的回复,他们说当违反某些条件时(如@AndrasDeak所解释的那样),它确实会自动切换到光栅化模式(他们没有解释如何)。所以覆盖的方法是在打印参数中使用-painters扩展,唯一的缺点是输出文件的大小会呈非线性增长,这明确取决于输出图形的复杂性。 - Raaja_is_at_topanswers.xyz
继续说,当使用-painters扩展来覆盖内部开关时,我最终得到的.eps文件大小约为450 MB,这实际上是非常巨大的,因为它们需要被重复使用于文档目的。 - Raaja_is_at_topanswers.xyz
显示剩余5条评论
1个回答

4
对于所有指导我到这里(并且将来可能遇到同样问题的人),我收到了Mathworks的回复,他们说当违反某些条件时(就像@AndrasDeak解释的那样),它确实会自动切换到光栅化模式(他们没有解释如何)。因此,覆盖的方法是在打印参数中使用 -painters 扩展,唯一的缺点是输出文件的大小以非线性方式增加,其明确取决于输出图形的复杂性。
我还应该说的是,当使用 -painters 扩展来覆盖内部开关时,在我的情况下,最终得到的 .eps 大小约为450 MB,当需要重新用于文档目的时,实际上是巨大的。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接