From 2942be0e69e1d8cc90c062a336918b492598774f Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Tue, 11 Feb 2014 15:50:07 +0100 Subject: [PATCH] reporting test: pass xTickLabels explicitly --- tests/reporting/CountryGraphPage.m | 26 ++++++++++++++++++++------ tests/reporting/runDynareReport.m | 27 +++++++++++++++++++++------ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/tests/reporting/CountryGraphPage.m b/tests/reporting/CountryGraphPage.m index 3b38b225e..1c5cc56dc 100644 --- a/tests/reporting/CountryGraphPage.m +++ b/tests/reporting/CountryGraphPage.m @@ -16,10 +16,14 @@ function rep = CountryGraphPage(rep, countryAbbr, db_q, dc_q, prange, srange) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. +shaded = strings(srange(1)); +endpoint = strings(prange(end)); rep = rep.addGraph('title', 'Interest Rate', ... 'xrange', prange, ... 'shade', srange, ... - 'showZeroline', true); + 'showZeroline', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); rep = rep.addSeries('data', db_q{['RS_' countryAbbr]}, ... 'graphLineColor', 'blue', ... 'graphLineStyle', 'dashed', ... @@ -31,7 +35,9 @@ rep = rep.addSeries('data', dc_q{['RS_' countryAbbr]}, ... rep = rep.addGraph('title', 'Output Gap', ... 'xrange', prange, ... 'shade', srange, ... - 'showZeroline', true); + 'showZeroline', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); rep = rep.addSeries('data', db_q{['Y_' countryAbbr]}, ... 'graphLineColor', 'blue', ... 'graphLineStyle', 'dashed', ... @@ -43,7 +49,9 @@ rep = rep.addSeries('data', dc_q{['Y_' countryAbbr]}, ... rep = rep.addGraph('title', 'Headline Inflation (y/y)', ... 'xrange', prange, ... 'shade', srange, ... - 'showZeroline', true); + 'showZeroline', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); rep = rep.addSeries('data', db_q{['PCH_PIE4_' countryAbbr]}, ... 'graphLineColor', 'blue', ... 'graphLineStyle', 'dashed', ... @@ -55,7 +63,9 @@ rep = rep.addSeries('data', dc_q{['PCH_PIE4_' countryAbbr]}, ... rep = rep.addGraph('title', 'Headline Inflation (q/q)', ... 'xrange', prange, ... 'shade', srange, ... - 'showZeroline', true); + 'showZeroline', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); rep = rep.addSeries('data', db_q{['PCH_PIE_' countryAbbr]}, ... 'graphLineColor', 'blue', ... 'graphLineStyle', 'dashed', ... @@ -67,7 +77,9 @@ rep = rep.addSeries('data', dc_q{['PCH_PIE_' countryAbbr]}, ... rep = rep.addGraph('title', 'GDP Growth (q/q)', ... 'xrange', prange, ... 'shade', srange, ... - 'showZeroline', true); + 'showZeroline', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); rep = rep.addSeries('data', db_q{['PCH_GROWTH_' countryAbbr]}, ... 'graphLineColor', 'blue', ... 'graphLineStyle', 'dashed', ... @@ -79,7 +91,9 @@ rep = rep.addSeries('data', dc_q{['PCH_GROWTH_' countryAbbr]}, ... rep = rep.addGraph('title', 'Core Inflation (y/y)', ... 'xrange', prange, ... 'shade', srange, ... - 'showZeroline', true); + 'showZeroline', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); rep = rep.addSeries('data', db_q{['PCH_PIEX4_' countryAbbr]}, ... 'graphLineColor', 'blue', ... 'graphLineStyle', 'dashed', ... diff --git a/tests/reporting/runDynareReport.m b/tests/reporting/runDynareReport.m index 08c04cdfc..d337ebdac 100644 --- a/tests/reporting/runDynareReport.m +++ b/tests/reporting/runDynareReport.m @@ -23,6 +23,9 @@ prange = dates('2007q1'):dates('2013q4'); forecast_date = dates('2012q2'); srange = forecast_date:prange(end); +shaded = strings(srange(1)); +endpoint = strings(prange(end)); + shortNames = {'US', 'EU', 'JA', 'EA6', 'LA6', 'RC6'}; longNames = {'Coca Cola', 'Kinder Bueno', 'Pizza', ... 'Vegetarianism Is Good', 'OS X', 'Dothraki'}; @@ -147,7 +150,9 @@ rep = rep.addSection('height', '60mm'); rep = rep.addGraph('title', 'World Real Oil Price Index', ... 'xrange', prange, ... 'shade', srange, ... - 'showLegend', true); + 'showLegend', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); db_q = db_q.tex_rename('LRPOIL_WORLD', 'Oil Price'); rep = rep.addSeries('data', db_q{'LRPOIL_WORLD'}, ... 'graphLineColor', 'blue', ... @@ -162,7 +167,9 @@ rep = rep.addSeries('data', db_q{'LRPOIL_BAR_WORLD'}, ... rep = rep.addGraph('title', 'World Real Food Price Index', ... 'xrange', prange, ... 'shade', srange, ... - 'showLegend', true); + 'showLegend', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); db_q = db_q.tex_rename('LRPFOOD_WORLD', 'Food Price'); rep = rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ... 'graphLineColor', 'blue', ... @@ -182,7 +189,9 @@ rep = rep.addSection('cols', 2); rep = rep.addGraph('title', 'World Real Oil Price', ... 'xrange', prange, ... 'shade', srange, ... - 'showLegend', true); + 'showLegend', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); rep = rep.addSeries('data', db_q{'LRPOIL_WORLD'}, ... 'graphLineColor', 'blue', ... 'graphLineWidth', 1.5); @@ -194,7 +203,9 @@ rep = rep.addSeries('data', dc_q{'LRPOIL_WORLD'}, ... rep = rep.addGraph('title', 'Equilibrium World Real Oil Price', ... 'xrange', prange, ... 'shade', srange, ... - 'showLegend', true); + 'showLegend', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); rep = rep.addSeries('data', db_q{'LRPOIL_BAR_WORLD'}, ... 'graphLineColor', 'blue', ... 'graphLineWidth', 1.5); @@ -206,7 +217,9 @@ rep = rep.addSeries('data', dc_q{'LRPOIL_BAR_WORLD'}, ... rep = rep.addGraph('title', 'World Real Food Price', ... 'xrange', prange, ... 'shade', srange, ... - 'showLegend', true); + 'showLegend', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); rep = rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ... 'graphLineColor', 'blue', ... 'graphLineWidth', 1.5); @@ -218,7 +231,9 @@ rep = rep.addSeries('data', dc_q{'LRPFOOD_WORLD'}, ... rep = rep.addGraph('title', 'Equilibrium World Real Food Price', ... 'xrange', prange, ... 'shade', srange, ... - 'showLegend', true); + 'showLegend', true, ... + 'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ... + 'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}}); rep = rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ... 'graphLineColor', 'blue', ... 'graphLineWidth', 1.5); -- GitLab