diff --git a/doc/dseries-and-reporting/dseriesReporting.tex b/doc/dseries-and-reporting/dseriesReporting.tex index ff8955426..040a1d573 100644 --- a/doc/dseries-and-reporting/dseriesReporting.tex +++ b/doc/dseries-and-reporting/dseriesReporting.tex @@ -896,8 +896,8 @@ r = report(); @# for var in endovars r = r.addGraph(`data', shock@{shock}.@{var}, `title', `@{var}', ... `showGrid', false, `yTickLabelPrecision', 2, ... - `yTickLabelZeroFill', false); - r = r.addSeries(`graphHline', 0, `graphLineColor', `red'); + `yTickLabelZeroFill', false, ... + `showZeroLine', true, `zeroLineColor', 'red'); @# endfor r = r.addVspace(`number', 2); r = r.addSection(`cols', 1); diff --git a/doc/dynare.texi b/doc/dynare.texi index 7f6f1f9d1..4588b2b31 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -11239,7 +11239,7 @@ command. Default: @code{`!'} @end defmethod @anchor{addGraph} -@defmethod Report addGraph data, graphDirName, graphName, graphSize, height, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, miscTikzAxisOptions, miscTikzPictureOptions, seriesToUse, shade, shadeColor, shadeOpacity, title, width, xlabel, ylabel, xAxisTight, xrange, xTicks, xTickLabels, xTickLabelAnchor, xTickLabelRotation, yAxisTight, yTickLabelFixed, yTickLabelPrecision, yTickLabelZeroFill, yrange, showZeroline +@defmethod Report addGraph data, graphDirName, graphName, graphSize, height, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, miscTikzAxisOptions, miscTikzPictureOptions, seriesToUse, shade, shadeColor, shadeOpacity, title, width, xlabel, ylabel, xAxisTight, xrange, xTicks, xTickLabels, xTickLabelAnchor, xTickLabelRotation, yAxisTight, yTickLabelFixed, yTickLabelPrecision, yTickLabelZeroFill, yrange, showZeroline, zeroLineColor Adds a @code{Graph} to a @code{Section}. @optionshead @table @code @@ -11390,9 +11390,14 @@ The precision with which to report the yTickLabel. Default: @code{1} @item yTickLabelZeroFill, @code{BOOLEAN} Whether or not to fill missing precision spots with zeros. Default: @code{true} +@anchor{showZeroLine} @item showZeroline, @code{BOOLEAN} Display a solid black line at @math{y = 0}. Default: @code{false} +@item zeroLineColor, @code{`red'} | @code{`green'} | @code{`blue'} | @code{`cyan'} | @code{`magenta'} | @code{`yellow'} | @code{`black'} | @code{`gray'} | @code{`darkgray'} | @code{`lightgray'} | @code{`brown'} | @code{`lime'} | @code{`olive'} | @code{`orange'} | @code{`pink'} | @code{`purple'} | @code{`teal'} | @code{`violet'} | @code{`white'} +The color to use for the zero line. Only used if @ref{showZeroLine} is +true. Default: @code{`black'} + @end table @end defmethod diff --git a/matlab/ep/solve_stochastic_perfect_foresight_model_1.m b/matlab/ep/solve_stochastic_perfect_foresight_model_1.m index d27b50d28..56249d3c6 100644 --- a/matlab/ep/solve_stochastic_perfect_foresight_model_1.m +++ b/matlab/ep/solve_stochastic_perfect_foresight_model_1.m @@ -1,4 +1,4 @@ -function [flag,endo_simul,err] = solve_stochastic_perfect_foresight_model_1(endo_simul,exo_simul,Options,pfm,order,varargin) +function [flag,endo_simul,err,y] = solve_stochastic_perfect_foresight_model_1(endo_simul,exo_simul,Options,pfm,order,varargin) % Copyright (C) 2012-2013 Dynare Team % @@ -63,7 +63,6 @@ if ~isempty(k) else error('there is no nodes equal to zero') end - if hybrid_order > 0 if hybrid_order == 2 h_correction = 0.5*dr.ghs2(dr.inv_order_var); @@ -97,7 +96,7 @@ block_nbr = pfm.block_nbr; dimension = ny*block_nbr; pfm.dimension = dimension; if order == 0 - i_upd_r = (1:ny*periods); + i_upd_r = (1:ny*periods)'; i_upd_y = i_upd_r + ny; else i_upd_r = zeros(dimension,1); diff --git a/matlab/reports/@graph/graph.m b/matlab/reports/@graph/graph.m index 2d9f97560..d9bab8480 100644 --- a/matlab/reports/@graph/graph.m +++ b/matlab/reports/@graph/graph.m @@ -62,6 +62,7 @@ o.legendOrientation = 'horizontal'; o.legendFontSize = 'tiny'; o.showZeroline = false; +o.zeroLineColor = 'black'; o.graphSize = []; o.xTicks = []; @@ -132,12 +133,13 @@ assert(ischar(o.xTickLabelAnchor), '@graph.graph: xTickLabelAnchor must be a str assert(isint(o.yTickLabelPrecision), '@graph.graph: o.yTickLabelPrecision must be an integer'); assert(islogical(o.yTickLabelFixed), '@graph.graph: yTickLabelFixed must be either true or false'); assert(islogical(o.yTickLabelZeroFill), '@graph.graph: yTickLabelZeroFill must be either true or false'); - valid_shadeColor = {'red', 'green', 'blue', 'cyan ', 'magenta', 'yellow', ... 'black', 'gray', 'darkgray', 'lightgray', 'brown', ... 'lime', 'olive', 'orange', 'pink', 'purple', 'teal', 'violet', 'white'}; assert(any(strcmp(o.shadeColor, valid_shadeColor)), ['@graph.graph: shadeColor must be one of ' ... strjoin(valid_shadeColor)]); +assert(any(strcmp(o.zeroLineColor, valid_shadeColor)), ... + ['@graph.graph: zeroLineColor must be one of ' strjoin(valid_shadeColor)]); valid_legend_locations = ... {'south west','south east','north west','north east','outer north east'}; diff --git a/matlab/reports/@graph/writeGraphFile.m b/matlab/reports/@graph/writeGraphFile.m index bfa480245..79b8af745 100644 --- a/matlab/reports/@graph/writeGraphFile.m +++ b/matlab/reports/@graph/writeGraphFile.m @@ -212,7 +212,8 @@ if ~isempty(o.shade) end if o.showZeroline - fprintf(fid, '%%zeroline\n\\addplot[black,line width=.5,forget plot] coordinates {(1,0)(%d,0)};\n',dd.ndat); + fprintf(fid, '%%zeroline\n\\addplot[%s,line width=.5,forget plot] coordinates {(1,0)(%d,0)};\n', ... + o.zeroLineColor, dd.ndat); end for i=1:ne diff --git a/tests/reporting/example1.mod b/tests/reporting/example1.mod index bec34f5b5..10b2aef3c 100644 --- a/tests/reporting/example1.mod +++ b/tests/reporting/example1.mod @@ -65,8 +65,9 @@ r = report(); r = r.addSection('cols', 2); @# for var in endovars r = r.addGraph('data', shock@{shock}.@{var}, 'title', '@{var}', ... - 'showGrid', false, 'yTickLabelPrecision', 2, 'yTickLabelZeroFill', false); - r = r.addSeries('graphHline', 0, 'graphLineColor', 'red'); + 'showGrid', false, 'yTickLabelPrecision', 2, ... + 'yTickLabelZeroFill', false, ... + 'showZeroLine', true, 'zeroLineColor', 'red'); @# endfor r = r.addVspace('number', 2); r = r.addSection('cols', 1);