-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrintFigToPaper.m
45 lines (43 loc) · 1.66 KB
/
PrintFigToPaper.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function [] = PrintFigToPaper (OutputType,plotFileName,...
FigFontSize,FigFontName,FigWidth,IsPrint,IsPrintTime,IsCustomHeight,FigHeightCustom,IsHideAxis)
% OutputType = -depsc -dpdf -dpng
% FigFontSize = 16;
% FigFontName = 'Times New Roman';
% FigWidth = 7; %inches
% IsPrint = 1; %flag: 1-output this figure
% IsPrintTime = 0; %flag: 0-do not append a timestamp to the filename
% IsCustomHeight = 0; %flag: 0-the figure height is automatically adapted
% FigHeightCustom = 5; %(OPTIONAL)
% IsHideAxis = 0; %(OPTIONAL) flag: 0-Hide the Axes
numdip = 300;
set(gcf,'PaperUnits','inches');
set(gcf,'Units','inches');
if nargin >= 10 && IsHideAxis == 1
set(gca, 'xcolor', 'none', 'ycolor', 'none');
else
set(gca,'color','none');
end
screenposition = get(gcf,'Position');
FigHeight = FigWidth/screenposition(3)*screenposition(4);
if nargin > 7 && IsCustomHeight
FigHeight = FigHeightCustom;
end
set(gcf,'PaperPosition',[0 2 FigWidth FigHeight]);
set(gcf,'Position',[screenposition(1:2)/2 FigWidth FigHeight]);
set([get(gca,'XLabel'),get(gca,'YLabel')],...
'FontSize',FigFontSize,'FontName', FigFontName);
set(findobj('FontSize',10),'FontSize',FigFontSize);
set(findobj('FontName','Helvetica'),'FontName', FigFontName);
set(findobj('FontSize',10),'FontSize',FigFontSize);
set(findobj('FontSize',16),'FontSize',FigFontSize);
% output
if ~exist('pic','dir')
mkdir('pic');
end
if(IsPrint && 1)
if(IsPrintTime && 1)
print(gcf,OutputType,'-painters',['-r',num2str(numdip)],['pic/',plotFileName,datestr(clock,30)]);
else
print(gcf,OutputType,'-painters',['-r',num2str(numdip)],['pic/',plotFileName]);
end
end