diff --git a/matlab/reports/@graph/writeGraphFile.m b/matlab/reports/@graph/writeGraphFile.m index 039da1ff693fb43e7334f5b3d586b5fdaa63375f..a0d2273a4485d112a332d919a54aa8a36d28bf6b 100644 --- a/matlab/reports/@graph/writeGraphFile.m +++ b/matlab/reports/@graph/writeGraphFile.m @@ -185,11 +185,23 @@ if ~isempty(o.shade) assert(~isempty(x1) && ~isempty(x2), ['@graph.writeGraphFile: either ' ... date2string(o.shade(1)) ' or ' date2string(o.shade(end)) ' is not in the date ' ... 'range of data selected.']); - fprintf(fid,['\\begin{pgfonlayer}{background}\n\\fill[%s!%f]\n(axis ' ... - 'cs:%f,\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ... - 'cs:\\pgfkeysvalueof{/pgfplots/xmax},\\pgfkeysvalueof{/' ... - 'pgfplots/ymax});\n\\end{pgfonlayer}\n'], ... - o.shadeColor, o.shadeOpacity,x1); + if x1 == 1 + fprintf(fid,['\\begin{pgfonlayer}{background}\n\\fill[%s!%f]\n(axis ' ... + 'cs:\\pgfkeysvalueof{/pgfplots/xmin},\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ... + 'cs:%f,\\pgfkeysvalueof{/pgfplots/ymax});\n\\end{pgfonlayer}\n'], ... + o.shadeColor, o.shadeOpacity, x2); + elseif x2 == dd.ndat + fprintf(fid,['\\begin{pgfonlayer}{background}\n\\fill[%s!%f]\n(axis ' ... + 'cs:%f,\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ... + 'cs:\\pgfkeysvalueof{/pgfplots/xmax},\\pgfkeysvalueof{/' ... + 'pgfplots/ymax});\n\\end{pgfonlayer}\n'], ... + o.shadeColor, o.shadeOpacity, x1); + else + fprintf(fid,['\\begin{pgfonlayer}{background}\n\\fill[%s!%f]\n(axis ' ... + 'cs:%f,\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ... + 'cs:%f,\\pgfkeysvalueof{/pgfplots/ymax});\n\\end{pgfonlayer}\n'], ... + o.shadeColor, o.shadeOpacity, x1, x2); + end end fprintf(fid, '\\end{axis}\n\\end{tikzpicture}\n'); diff --git a/tests/reporting/runDynareReport.m b/tests/reporting/runDynareReport.m index 684a320fdc81a6c36471925f5b8d6ba021797f6d..5a08c73d6392b466a7970abcec2769d7cb0a2ed3 100644 --- a/tests/reporting/runDynareReport.m +++ b/tests/reporting/runDynareReport.m @@ -205,12 +205,10 @@ rep = rep.addSeries('data', dc_q{'LRPOIL_WORLD'}, ... 'graphLineStyle', 'dashed', ... 'graphLineWidth', 1.5); +srange1 = prange(1):forecast_date; rep = rep.addGraph('title', 'Equilibrium World Real Oil Price', ... 'xrange', prange, ... - 'shade', srange, ... - 'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ... - 'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},... - 'xTickLabelRotation', 0); + 'shade', srange1); rep = rep.addSeries('data', db_q{'LRPOIL_BAR_WORLD'}, ... 'graphLineColor', 'blue', ... 'graphLineWidth', 1.5);