


function dyn_save_graph(dirname,graph_name,graph_formats,TeX,names,texnames,caption)
saves Dynare graphs
INPUTS
graph_name (string) name of the graph (used as file name)
graph_formats (struct) list of graph formats to be used
TeX (logical) whether to make TeX snippet
OUTPUTS
none
SPECIAL REQUIREMENTS
none
Copyright (C) 2011 Dynare Team
This file is part of Dynare.
Dynare is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dynare is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Dynare. If not, see <http://www.gnu.org/licenses/>.

0001 function dyn_save_graph(dirname,graph_name,graph_formats,TeX,names,texnames,caption) 0002 % function dyn_save_graph(dirname,graph_name,graph_formats,TeX,names,texnames,caption) 0003 % saves Dynare graphs 0004 % 0005 % INPUTS 0006 % graph_name (string) name of the graph (used as file name) 0007 % graph_formats (struct) list of graph formats to be used 0008 % TeX (logical) whether to make TeX snippet 0009 % 0010 % OUTPUTS 0011 % none 0012 % 0013 % SPECIAL REQUIREMENTS 0014 % none 0015 % 0016 % Copyright (C) 2011 Dynare Team 0017 % 0018 % This file is part of Dynare. 0019 % 0020 % Dynare is free software: you can redistribute it and/or modify 0021 % it under the terms of the GNU General Public License as published by 0022 % the Free Software Foundation, either version 3 of the License, or 0023 % (at your option) any later version. 0024 % 0025 % Dynare is distributed in the hope that it will be useful, 0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0028 % GNU General Public License for more details. 0029 % 0030 % You should have received a copy of the GNU General Public License 0031 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0032 0033 create_dir(dirname); 0034 graph_name = [dirname filesep regexprep(graph_name,' ','_')]; 0035 if nargin <= 2 0036 TeX = 0; 0037 elseif nargin <= 4 0038 names = {}; 0039 texnames = {}; 0040 elseif nargin <= 6 0041 caption = ''; 0042 end 0043 0044 if graph_formats.eps || TeX 0045 print([ graph_name '.eps' ],'-depsc2'); 0046 end 0047 if graph_formats.pdf && ~exist(OCTAVE_VERSION) 0048 print(graph_name,'-dpdf'); 0049 end 0050 if graph_formats.fig && ~exist(OCTAVE_VERSION) 0051 print(graph_name,'-dfig'); 0052 end 0053 0054 if TeX 0055 fh = fopen([graph_name '.tex'],'w'); 0056 for i=1:length(names) 0057 fprintf(fh,'\\psfrag{%s}[1][][0.5][0]{%s}\n',names{i},texnames{i}); 0058 end 0059 fprintf(fh,'\\centering \n'); 0060 fprintf(fh,'\\includegraphics[scale=0.5]{%s}\n',graph_name); 0061 if caption 0062 fprintf(fh,'\\caption{%s}',caption); 0063 end 0064 fprintf(fh,'\\label{Fig:%s}\n',graph_name); 0065 fprintf(fh,'\\end{figure}\n'); 0066 fprintf(fh,'\n'); 0067 fprintf(fh,'%% End of TeX file.\n'); 0068 fclose(fh); 0069 end