【发布时间】:2017-05-05 12:51:10
【问题描述】:
当我尝试将Matlab 的 3d 图(实际上只有这个图)打印为 .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。
The necessary data file E_fw.mat is available in the g-drive link inside the data.zip
【问题讨论】:
-
不要将我们定向到其他网站,而是以minimal reproducible example 的形式提供您帖子中的所有数据。同时也试试 Yair Altman 的export_fig。
-
@SardarUsama 我宁愿给出那个,但我不知道如何在这里上传数据文件
.mat,因为我在这里使用了一些数据文件来创建图形,并且仅用于此特殊情况下问题反复出现。无论如何,我现在将发布MWE,也请指导我如何发布必要的数据文件。 -
不要上传文件,而是提供能够重现您的问题的最少数据。
-
@SardarUsama 是的,我明白了,问题是重现问题所需的最小数据文件是 7MB,所以我在这里给出了
script和g-drive中的数据,但是,特定的数据集,我不知道如何给它作为 MWE。 -
您是否也阅读/尝试过 Sardar 的使用
export_fig的建议?或者我一直使用的内置saveas:saveas(g,'outname.eps','epsc')。虽然我会发现 MATLAB 基于一些启发式方法切换到光栅化是可能,但我可以(意外地)在过去生成矢量化的 150MB eps 表面图文件而没有任何问题,所以如果这个我会感到惊讶就是这样。
标签: matlab matlab-figure eps