reporting: new option xTickLabelRotation

time-shift
Houtan Bastani 2014-02-11 16:37:15 +01:00
parent 0954ce3770
commit 6bbae11b66
5 changed files with 47 additions and 27 deletions

View File

@ -10704,7 +10704,7 @@ command. Default: @code{`!'}
@end table
@end defmethod
@defmethod Report addGraph data, figname, figDirName, graphSize, height, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, seriesToUse, shade, shadeColor, shadeOpacity, title, width, xlabel, ylabel, xrange, xTicks, xTickLabels, yrange, showZeroline
@defmethod Report addGraph data, figname, figDirName, graphSize, height, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, seriesToUse, shade, shadeColor, shadeOpacity, title, width, xlabel, ylabel, xrange, xTicks, xTickLabels, xTickLabelRotation, yrange, showZeroline
Adds a @code{Graph} to a @code{Section}.
@optionshead
@table @code
@ -10794,6 +10794,9 @@ begin at @math{1}. Default: set by Matlab/Octave.
The labels to be mapped to the ticks provided by
@ref{xTicks}. Default: the dates of the @code{dseries}
@item xTickLabelRotation, @code{DOUBLE}
The amount to rotate the x tick labels by. Default: @code{45}
@item yrange, @code{NUMERICAL_VECTOR}
The boundary on the y-axis to display in the graph, represented as a
@code{NUMERICAL_VECTOR} of size @math{2}, with the first entry less

View File

@ -63,6 +63,7 @@ o.showZeroline = false;
o.graphSize = [];
o.xTicks = [];
o.xTickLabels = {};
o.xTickLabelRotation = 45;
o.width = 6;
o.height = 4.5;
@ -109,6 +110,7 @@ assert(isfloat(o.shadeOpacity) && length(o.shadeOpacity)==1 && ...
'@graph.graph: o.shadeOpacity must be a real in [0 1]');
assert(isfloat(o.width), '@graph.graph: o.width must be a real number');
assert(isfloat(o.height), '@graph.height: o.width must be a real number');
assert(isfloat(o.xTickLabelRotation), '@graph.graph: o.xTickLabelRotation must be a real number');
valid_legend_locations = ...
{'North', 'South', 'East', 'West', ...

View File

@ -86,14 +86,15 @@ for i = 1:length(x)
fprintf(fid,',');
end
end
fprintf(fid, '},\nx tick label style={rotate=45,anchor=east},\n');
fprintf(fid, '},\nx tick label style={rotate=%f},\n',o.xTickLabelRotation);
fprintf(fid, ['width=%fin,\n'...
'height=%fin,\n'...
'scale only axis,\n'...
'xmin=1,\n'...
'xmax=%d,\n'...
'ymin=%d,\n'...
'ymax=%d,\n'], o.width, o.height, dd.ndat, ymin, ymax);
'ymax=%d,\n'...
'axis lines=box,\n'], o.width, o.height, dd.ndat, ymin, ymax);
if o.showGrid
fprintf(fid, 'xmajorgrids=true,\nymajorgrids=true,\n');

View File

@ -16,14 +16,16 @@ 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/>.
startpoint = strings(prange(1));
shaded = strings(srange(1));
endpoint = strings(prange(end));
rep = rep.addGraph('title', 'Interest Rate', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
rep = rep.addSeries('data', db_q{['RS_' countryAbbr]}, ...
'graphLineColor', 'blue', ...
'graphLineStyle', 'dashed', ...
@ -36,8 +38,9 @@ rep = rep.addGraph('title', 'Output Gap', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
rep = rep.addSeries('data', db_q{['Y_' countryAbbr]}, ...
'graphLineColor', 'blue', ...
'graphLineStyle', 'dashed', ...
@ -50,8 +53,9 @@ rep = rep.addGraph('title', 'Headline Inflation (y/y)', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
rep = rep.addSeries('data', db_q{['PCH_PIE4_' countryAbbr]}, ...
'graphLineColor', 'blue', ...
'graphLineStyle', 'dashed', ...
@ -64,8 +68,9 @@ rep = rep.addGraph('title', 'Headline Inflation (q/q)', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
rep = rep.addSeries('data', db_q{['PCH_PIE_' countryAbbr]}, ...
'graphLineColor', 'blue', ...
'graphLineStyle', 'dashed', ...
@ -78,8 +83,9 @@ rep = rep.addGraph('title', 'GDP Growth (q/q)', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
rep = rep.addSeries('data', db_q{['PCH_GROWTH_' countryAbbr]}, ...
'graphLineColor', 'blue', ...
'graphLineStyle', 'dashed', ...
@ -92,8 +98,9 @@ rep = rep.addGraph('title', 'Core Inflation (y/y)', ...
'xrange', prange, ...
'shade', srange, ...
'showZeroline', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
rep = rep.addSeries('data', db_q{['PCH_PIEX4_' countryAbbr]}, ...
'graphLineColor', 'blue', ...
'graphLineStyle', 'dashed', ...

View File

@ -23,6 +23,7 @@ prange = dates('2007q1'):dates('2013q4');
forecast_date = dates('2012q2');
srange = forecast_date:prange(end);
startpoint = strings(prange(1));
shaded = strings(srange(1));
endpoint = strings(prange(end));
@ -151,8 +152,9 @@ rep = rep.addGraph('title', 'World Real Oil Price Index', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
db_q = db_q.tex_rename('LRPOIL_WORLD', 'Oil Price');
rep = rep.addSeries('data', db_q{'LRPOIL_WORLD'}, ...
'graphLineColor', 'blue', ...
@ -168,8 +170,9 @@ rep = rep.addGraph('title', 'World Real Food Price Index', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
db_q = db_q.tex_rename('LRPFOOD_WORLD', 'Food Price');
rep = rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...
'graphLineColor', 'blue', ...
@ -190,8 +193,9 @@ rep = rep.addGraph('title', 'World Real Oil Price', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
rep = rep.addSeries('data', db_q{'LRPOIL_WORLD'}, ...
'graphLineColor', 'blue', ...
'graphLineWidth', 1.5);
@ -204,8 +208,9 @@ rep = rep.addGraph('title', 'Equilibrium World Real Oil Price', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
rep = rep.addSeries('data', db_q{'LRPOIL_BAR_WORLD'}, ...
'graphLineColor', 'blue', ...
'graphLineWidth', 1.5);
@ -218,8 +223,9 @@ rep = rep.addGraph('title', 'World Real Food Price', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
rep = rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...
'graphLineColor', 'blue', ...
'graphLineWidth', 1.5);
@ -232,8 +238,9 @@ rep = rep.addGraph('title', 'Equilibrium World Real Food Price', ...
'xrange', prange, ...
'shade', srange, ...
'showLegend', true, ...
'xTicks', [5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}});
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
rep = rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
'graphLineColor', 'blue', ...
'graphLineWidth', 1.5);