dynare/matlab/reports/@graph/graph.m

80 lines
1.9 KiB
Matlab
Raw Normal View History

2013-02-15 16:52:35 +01:00
function o = graph(varargin)
%function o = graph(varargin)
% Graph Class Constructor
%
% INPUTS
% 0 args => empty graph
% 1 arg (graph class) => copy object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013 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/>.
o = struct;
2013-02-19 15:48:47 +01:00
o.config = '';
o.title = '';
o.ylabel = '';
o.xlabel = '';
o.zlabel = '';
2013-02-15 16:52:35 +01:00
o.footnote = '';
2013-02-19 15:48:47 +01:00
o.figname = '';
2013-02-15 16:52:35 +01:00
o.data = '';
2013-03-08 18:59:26 +01:00
o.seriestouse = 'all';
2013-02-19 15:48:47 +01:00
o.shade = ''; %{1959q1:1964q4}
2013-03-07 15:45:53 +01:00
o.grid = true;
2013-02-19 15:48:47 +01:00
o.legend = false;
o.legend_location = 'SouthEast';
o.legend_orientation = 'horizontal';
o.legend_font_size = 8;
2013-02-15 16:52:35 +01:00
if nargin == 1
2013-03-08 19:25:24 +01:00
assert(isa(varargin{1}, 'graph'),['@graph.graph: with one arg you ' ...
'must pass a graph object']);
2013-02-15 16:52:35 +01:00
o = varargin{1};
return;
elseif nargin > 1
if round(nargin/2) ~= nargin/2
2013-03-08 19:25:24 +01:00
error(['@graph.graph: options must be supplied in name/value ' ...
2013-02-15 16:52:35 +01:00
'pairs.']);
end
optNames = lower(fieldnames(o));
% overwrite default values
for pair = reshape(varargin, 2, [])
field = lower(pair{1});
if any(strmatch(field, optNames, 'exact'))
o.(field) = pair{2};
else
2013-03-08 19:25:24 +01:00
error('@graph.graph: %s is not a recognized option.', field);
2013-02-15 16:52:35 +01:00
end
end
end
% Create graph object
o = class(o, 'graph');
end