Why does MATLAB not export EPS files properly?
이전 댓글 표시
Also, when I generate EPS files from MATLAB, I seem to be getting unusually large files that are displaced to the bottom left hand side of your image, leaving a large white border on two sides. Sometimes the files appear tiled.
채택된 답변
추가 답변 (1개)
Johannes Kalliauer
2022년 1월 19일
I would recommend to use 'ContentType','vector' of https://de.mathworks.com/help/matlab/ref/exportgraphics.html
%EPS
exportgraphics(gcf,'myVectorFile.eps','BackgroundColor','none','ContentType','vector')
%PDF
exportgraphics(gcf,'myVectorFile.pdf','BackgroundColor','none','ContentType','vector')
an example:
clear
close all
warning('off','MATLAB:print:ContentTypeImageSuggested')%turn of Warning that it Vectorgraphics might be slow compared to raster, the difference is less than 10% for this example
gcf=figure(314159265);
sphere %plot3(X,Y,Z) %Plot your awesome plot
daspect([1 1 1])%assure that it is not distored
%% Uggly RasterOutput
disp('Rasterouptut')
print('-depsc','-tiff','-r300','UgglyRaster.eps')%uggly: Rastergraphics
print('-dpdf','UgglyRaster.pdf')%uggly: Rastergraphics
%% Vector Output1 (no border for PDF, and optional transparent background)
disp('exportgraphics')%for R2020a or newer https://de.mathworks.com/help/matlab/ref/exportgraphics.html
exportgraphics(gcf,'myVectorFile1.eps','BackgroundColor','none','ContentType','vector')
exportgraphics(gcf,'myVectorFile1.pdf','BackgroundColor','none','ContentType','vector')
%% Vector Output2
disp('-vector')%In R2022a -painters got replaced by -vector
print('-depsc','-tiff','-r300', '-painters','myVectorFile2.eps')%large filesize
print('-dpdf','-r300', '-painters','myVectorFile2.pdf')%uggly: has large white borders
%% Vector Ouptut3
disp('Painters') %https://www.mathworks.com/matlabcentral/answers/92521-why-does-matlab-not-export-eps-files-properly
set(gcf,'renderer','Painters')
print('-depsc','myVectorFile3.eps')%white background which is exeedes the eps-border, not transparent
print('-dpdf','myVectorFile3.pdf')%uggly: has large white borders
Best Regards
카테고리
도움말 센터 및 File Exchange에서 Printing and Saving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!