From 6733c83ff5f0bebe41137e218e40fea86f2068ed Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Fri, 20 Jun 2014 15:40:20 +0200 Subject: [PATCH] reporting: add graph option: zeroLineColor --- doc/dynare.texi | 7 ++++++- matlab/reports/@graph/graph.m | 4 +++- matlab/reports/@graph/writeGraphFile.m | 3 ++- tests/reporting/example1.mod | 5 +++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index d0aed6a71d..9ad6e91a7e 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/reports/@graph/graph.m b/matlab/reports/@graph/graph.m index 2d9f975606..d9bab84806 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 bfa480245b..79b8af7457 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 bec34f5b51..10b2aef3c8 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); -- GitLab