Commit bf97829e authored by Houtan Bastani's avatar Houtan Bastani
Browse files

reporting: support vertical lines

parent 2c6624a4
......@@ -182,7 +182,10 @@ end
for i=1:ne
o.series{i}.writeSeriesForGraph(fid, dd);
if o.showLegend
fprintf(fid, '\\addlegendentry{%s}\n', o.series{i}.getTexName());
le = o.series{i}.getTexName();
if ~isempty(le)
fprintf(fid, '\\addlegendentry{%s}\n', le);
end
end
end
......
function s = getTexName(o)
%function s = getTexName(o)
% Copyright (C) 2013 Dynare Team
% Copyright (C) 2013-2014 Dynare Team
%
% This file is part of Dynare.
%
......@@ -18,6 +18,12 @@ function s = getTexName(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(~isempty(o.data) && size(o.data, 2) == 1);
s = o.data.tex{:};
if isempty(o.data)
% for the case when there is no data in the series
% e.g. graphVline was passed
s = '';
else
assert(size(o.data,2) == 1);
s = o.data.tex{:};
end
end
\ No newline at end of file
......@@ -48,6 +48,8 @@ o.graphMarkerSize = 1;
o.graphMiscTikzAddPlotOptions = '';
o.graphVline = dates();
o.tableShowMarkers = false;
o.tableNegColor = 'red';
o.tablePosColor = 'blue';
......
......@@ -30,8 +30,10 @@ function o = writeSeriesForGraph(o, fid, xrange)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
%% Validate options provided by user
assert(~isempty(o.data) && isa(o.data, 'dseries'), ['@report_series.writeSeriesForGraph: must ' ...
'provide data as a dseries']);
if isempty(o.graphVline)
assert(~isempty(o.data) && isa(o.data, 'dseries'), ['@report_series.writeSeriesForGraph: must ' ...
'provide data as a dseries']);
end
assert(ischar(o.graphMiscTikzAddPlotOptions), ['@report_series.writeSeriesForGraph: ' ...
'graphMiscTikzAddPlotOptions file must be a string']);
......@@ -64,12 +66,40 @@ assert(isfloat(o.graphMarkerSize) && o.graphMarkerSize > 0, ...
assert(~(strcmp(o.graphLineStyle, 'none') && isempty(o.graphMarker)), ['@report_series.writeSeriesForGraph: ' ...
'you must provide at least one of graphLineStyle and graphMarker']);
% Validate xrange
% Validate graphVline
assert(isdates(o.graphVline), '@report_series.writeSeriesForGraph: graphVline must be a dates');
% Zero tolerance
assert(isfloat(o.zeroTol), '@report_series.write: zeroTol must be a float');
%% graphVline
if ~isempty(o.graphVline)
for i=1:o.graphVline.ndat
fprintf(fid, '%%vline %d\n\\begin{pgfonlayer}{background1}\n\\draw[color=%s,%s,line width=%fpt,line join=round',...
i, o.graphLineColor, o.graphLineStyle, o.graphLineWidth);
if ~isempty(o.graphMarker)
if isempty(o.graphMarkerEdgeColor)
o.graphMarkerEdgeColor = o.graphLineColor;
end
if isempty(o.graphMarkerFaceColor)
o.graphMarkerFaceColor = o.graphLineColor;
end
fprintf(fid, ',mark=%s,mark size=%f,every mark/.append style={draw=%s,fill=%s}',...
o.graphMarker,o.graphMarkerSize,o.graphMarkerEdgeColor,o.graphMarkerFaceColor);
end
if ~isempty(o.graphMiscTikzAddPlotOptions)
fprintf(fid, ',%s', o.graphMiscTikzAddPlotOptions);
end
stringsdd = strings(xrange);
x = find(strcmpi(date2string(o.graphVline(i)), stringsdd));
fprintf(fid, ['] (axis cs:%d,\\pgfkeysvalueof{/pgfplots/ymin}) -- (axis ' ...
'cs:%d,\\pgfkeysvalueof{/pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
x, x);
end
return
end
%%
if isempty(xrange) || all(xrange == o.data.dates)
ds = o.data;
......
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