matlab保存论文插图

matlab保存高清图片用于论文插图:

set(gcf, 'unit', 'centimeters', 'position', [20, 10, 8, 6.4]); % 设定图片物理尺寸宽8cm,高6.4cm
set(gca,'looseInset',[0 0 0 0]); % 去除多余白边
print(gcf, 'D:\desktop\figname.tif', '-r800', '-dtiff'); % Tif格式,分辨率800 

这里保存为tif格式,也可以保存为矢量图格式如eps, pdf,emf,svg等格式。

如果图片需要后处理可以先保存为svg格式,然后导入Visio中,取消组合后进行后处理。

 

采用saveas保存:

saveas(gcf,[savepath,'figname.eps'], 'psc2');
saveas(gcf,[savepath, 'figname.fig']);

 

去除保存的pdf的白边,可以指定输出的页面大小:

orient(gcf,'landscape') % 纸张改为横向
set(gcf,'color','white','paperpositionmode','auto');
fig = gcf;
fig_pos = fig.PaperPosition;
fig.PaperSize = [fig_pos(3)+0.1, fig_pos(4)+0.1]; % 原尺寸+0.1
saveas(gcf,[savepath,'Figure1.pdf'], 'pdf');

  

批量保存:

% 批量操作
clc;
path = 'G:\图';

dirOutput = dir(fullfile(path,'*.fig')); % 遍历文件夹下所有.fig文件
fileNames = {dirOutput.name}; % 得到带后缀的文件名cell

for i = 1:length(fileNames) % 对fig文件进行循环
    disp(i)
    
    [filepath, name, ext] = fileparts(fileNames{1, i}); % 将文件名与后缀分离
    
    % 打开fig文件
    uiopen([path, '\',fileNames{1, i}], 1)
    
    % 另存为pdf文件
    orient(gcf,'landscape') % 纸张改为横向
    set(gcf,'color','white','paperpositionmode','auto');
    fig = gcf;
    fig_pos = fig.PaperPosition;
    fig.PaperSize = [fig_pos(3)+1, fig_pos(4)+1]; % 原尺寸+1
    saveas(gcf,[path, '\', name, '.pdf'], 'pdf');
    
    % 关闭fig文件
    close all
end

  

 

参考:

https://zhuanlan.zhihu.com/p/181221621

https://zhuanlan.zhihu.com/p/131602083

https://zhuanlan.zhihu.com/p/57606534

posted on 2019-10-24 14:48  那抹阳光1994  阅读(861)  评论(0编辑  收藏  举报

导航