Commit 2116ab0f authored by Houtan Bastani's avatar Houtan Bastani
Browse files

reporting: xrange & yrange

parent 1d3dc377
...@@ -51,30 +51,35 @@ end ...@@ -51,30 +51,35 @@ end
%set(h, 'units', 'normalized', 'outerposition', [0 0 1 1]); %set(h, 'units', 'normalized', 'outerposition', [0 0 1 1]);
if strcmpi(o.seriestouse, 'all') if strcmpi(o.seriestouse, 'all')
data = o.data.data; ds = o.data;
else else
data = o.data{o.seriestouse{:}}.data; ds = o.data{o.seriestouse{:}};
end end
x=[1:1:o.data.nobs]; if ~strcmp(o.xrange, 'all')
xlabels=getDatesCellStringArray(o.data.time); dd1 = dynDate(o.xrange{1});
dd2 = dynDate(o.xrange{2});
ds = ds(dd1:dd2);
end
data = ds.data;
x = 1:1:ds.nobs;
xlabels = getDatesCellStringArray(ds.time);
plot(x, data); plot(x, data);
if ~strcmp(o.yrange, 'all')
ylim([o.yrange{:}]);
end
if ~isempty(o.shade) if ~isempty(o.shade)
x1 = strmatch(lower(o.shade{1}), xlabels, 'exact'); x1 = find(strcmp(o.shade{1}, xlabels));
x2 = strmatch(lower(o.shade{2}), xlabels, 'exact'); x2 = find(strcmp(o.shade{2}, xlabels));
assert(~isempty(x1) && ~isempty(x2), ['@graph.createGraph: either ' ...
o.shade{1} ' or ' o.shade{2} 'is not in the date ' ...
'range of data selected.']);
yrange = get(gca, 'YLim'); yrange = get(gca, 'YLim');
if isempty(x1)
error(['@graph.createGraph: ' o.shade{1} ' not in date range of ' ...
'provided data']);
end
if isempty(x2)
error(['@graph.createGraph: ' o.shade{2} ' not in date range of ' ...
'provided data']);
end
% From ShadePlotForEmpahsis (Matlab Exchange) % From ShadePlotForEmpahsis (Matlab Exchange)
% use patch bc area doesn't work with matlab2tikz % use patch bc area doesn't work with matlab2tikz
patch([repmat(x1, 1, 2) repmat(x2, 1, 2)], [yrange fliplr(yrange)], ... patch([repmat(x1, 1, 2) repmat(x2, 1, 2)], [yrange fliplr(yrange)], ...
...@@ -85,11 +90,7 @@ set(gca,'XTick', x); ...@@ -85,11 +90,7 @@ set(gca,'XTick', x);
set(gca,'XTickLabel', xlabels); set(gca,'XTickLabel', xlabels);
if o.legend if o.legend
if strcmpi(o.seriestouse, 'all') lh = legend(ds.name);
lh = legend(o.data.name);
else
lh = legend(o.seriestouse{:});
end
set(lh, 'orientation', o.legend_orientation); set(lh, 'orientation', o.legend_orientation);
set(lh, 'Location', o.legend_location); set(lh, 'Location', o.legend_location);
set(lh, 'FontSize', o.legend_font_size); set(lh, 'FontSize', o.legend_font_size);
......
...@@ -44,7 +44,9 @@ o.footnote = ''; ...@@ -44,7 +44,9 @@ o.footnote = '';
o.figname = ''; o.figname = '';
o.data = ''; o.data = '';
o.seriestouse = 'all'; o.seriestouse = 'all';
o.shade = ''; %{1959q1:1964q4} o.shade = '';
o.xrange = 'all';
o.yrange = 'all';
o.grid = true; o.grid = true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment