필터 지우기
필터 지우기

Matlab is not saving the whole figure in epsc2 format

조회 수: 3 (최근 30일)
mak
mak 2017년 4월 8일
댓글: mak 2017년 4월 14일
Hi,
I am having trouble in saving a figure in epsc2 format. Looks like matlab cuts out part of the figure while saving the figure. Below is the code I am suing where I set figure size in inches and set the renderer to painters. Sometimes matlab saves the whole figure as intended but most of the time it cuts out a significant part of the figure. I use matlab on ubuntu m/c with nvidia driver. Below is the code I am using,
LineStyles = {'-c', '--m','-.r',':g','-+b','-oc','-s','-d','-^','-*'}; % 10 types total
LineStyles1 = {'oc', 'om','or','og','ob','oc','om','-d','-^','-*'}; % 10 types total
figWidth = 3; figheight = figWidth/1; formatEng = '-depsc2';
set(groot,'defaultFigurePaperPositionMode','manual');
figure(); set(gcf,'Renderer','painters');
set(gcf, 'PaperUnits', 'inches', 'PaperPosition', [0 0 figWidth figheight]);
hold all;
counter = 0;
for kk = 1:2:length(heightVec)
counter = counter + 1;
%plot(kx_fourier.*(BLH/z_i), fourier_spectra_u_frame(kk,:).*kx_fourier./ustar^2, LineStyles{counter});
plot(kx_fourier.*z_vec(heightVec(kk))/z_i, fourier_spectra_u_frame(kk,:).*kx_fourier./ustar^2, LineStyles{counter});
%plot(kwave.*(BLH/z_i), wavelet_spectra_u_frame(kk,:).*kwave./ustar^2,LineStyles1{counter});
plot(kwave.*z_vec(heightVec(kk))/z_i, wavelet_spectra_u_frame(kk,:).*kwave./ustar^2,LineStyles1{counter});
end
xlabel('$k_x z$','Interpreter','Latex','FontSize',10);
ylabel('$k_x E_{11}(k_x)u_*^{-2}$','Interpreter','Latex','FontSize',10);
%xlim([0.05 50]);
%ylim([8e-9 0.00004]);
xx = [0.3 19];
loglog(xx,xx.^(-2/3).*1,'LineWidth',2); % -2/3 slope
text(5, 0.45, '-2/3','FontSize',8);
set(gca,'XScale','log'); set(gca,'YScale','log');
SPR = sprintf('%s','wavelet_n_fourier_spectra_ek02_pre.eps');
set(gcf, 'Color', 'w');
print(SPR, formatEng);
Can you please suggest me a way to solve the problem. I tried to find a solution online but did not find a solution.
Attached is the output I get.
  댓글 수: 1
mak
mak 2017년 4월 14일
I have found out a workaround. Not printing the figure to display solves the problem. So, basically, these two lines solve the problem.
fh = figure()
set(fh, 'Visible','off');

댓글을 달려면 로그인하십시오.

답변 (1개)

Saurabh Gupta
Saurabh Gupta 2017년 4월 12일
It is possible that print switches to OpenGL renderer for your figure, which causes this issue. You may want to specify the renderer for the print command to force it to use painters. This section of the documentation explains it.
"If you set the Renderer property for the figure, then print uses that renderer when generating output. Otherwise, print chooses the appropriate renderer. Typically, print uses the Painters renderer when generating vector graphics files. For some complex figures, print uses the OpenGL renderer instead. If it uses the OpenGL renderer, then the vector graphics file contains an embedded image, which might limit the extent to which you can edit the image in other applications. To ensure that print uses the Painters renderer, set the Renderer property for the figure to 'painters' or specify '-painters' as an input argument to print."

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by