Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • Dynare/dseries
  • sebastien/dseries
  • houtanb/dseries
  • wmutschl/dseries
  • DoraK/dseries
  • JohannesPfeifer/dseries
6 results
Show changes
Commits on Source (3)
function s = ndat(o)
% Given a one element dates object, returns a string with the formatted date.
% Returns the number of element in a dates object.
%
% INPUTS
% - o [dates]
%
% OUTPUTS
% - s [integer]
%
% REMARKS
% This method is deprecated, use length() instead
% Copyright © 2015-2022 Dynare Team
% Copyright © 2015-2024 Dynare Team
%
% This code is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
......
function h = plot(o, varargin)
% Overloads Matlab/Octave's plot function for dseries objects.
%
% INPUTS:
% - o [dseries] object containing n time series to be plotted in the same figure.
% - varargin [cell] optionally a second dseries object, and some options to be passed to the plot command.
%
% OUTPUTS:
% - h [handle] plot handle.
%
% REMARKS:
% [1] If n > 1 , additional arguments cannot be passed to the plot function for customization. However, the plot can be modified afterward using the plot handle.
% [2] If two dseries objects are provided, it is assumed that both contain only one observation (i.e., n = 1 ). The function will then plot the second variable against the first.
% Copyright © 2013-2017 Dynare Team
% Copyright © 2013-2025 Dynare Team
%
% This file is part of Dynare.
%
......@@ -55,23 +67,9 @@ switch ndseries
hh = plot(o.data);
end
axis tight;
id = get(gca,'XTick');
if isequal(id(1),0)
dates = strings([o.dates(1)-1,o.dates(id(2:end))]);
skip_relabeling=0;
else
ID = id(find(isint(id)));
if any(ID<o.dates(1).double) || any(ID>o.dates(end).double)
skip_relabeling=1; %hold on was used so that axis tight did not restrict current xlim to dseries used.
else
set(gca,'XTick',ID);
dates = strings(o.dates(ID));
skip_relabeling=0;
end
end
if ~skip_relabeling
set(gca,'XTickLabel',dates);
end
id = get(gca, 'XTick');
Dates = strings(o.dates(id));
set(gca,'XTickLabel', Dates);
case 2
[o0, o1] = align(o, varargin{1});
if isequal(nvariables,1)
......@@ -89,4 +87,4 @@ end
if nargout
h = hh;
end
\ No newline at end of file
end