diff --git a/doc/dynare.texi b/doc/dynare.texi index 82450b04df27da4d4ab8ba635aaafbf0acf4bb78..7ac192c37ba723f259ab17f55f959bf47197781e 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -10760,7 +10760,7 @@ the @ref{data} option. If empty, use all series provided to The date range showing the portion of the graph that should be shaded. Default: @code{none} -@item shadeColor, @code{MATLAB_COLOR_NAME} +@item shadeColor, @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 in the shaded portion of the graph. Default: @code{`green'} diff --git a/matlab/reports/@graph/graph.m b/matlab/reports/@graph/graph.m index 13a16945d83f9de0d96b417e934d51a220ca354d..1b1735789cfedd3f95fe54e828f2ddb847b040cc 100644 --- a/matlab/reports/@graph/graph.m +++ b/matlab/reports/@graph/graph.m @@ -104,7 +104,6 @@ assert(islogical(o.showGrid), '@graph.graph: showGrid must be either true or fal assert(islogical(o.showLegend), '@graph.graph: showLegend must be either true or false'); assert(islogical(o.showLegendBox), '@graph.graph: showLegendBox must be either true or false'); assert(islogical(o.showZeroline), '@graph.graph: showZeroline must be either true or false'); -assert(ischar(o.shadeColor), '@graph.graph: shadeColor must be a string'); assert(isfloat(o.shadeOpacity) && length(o.shadeOpacity)==1 && ... o.shadeOpacity >= 0 && o.shadeOpacity <= 1, ... '@graph.graph: o.shadeOpacity must be a real in [0 1]'); @@ -113,6 +112,12 @@ assert(isfloat(o.height), '@graph.graph: o.height must be a real number'); assert(isfloat(o.xTickLabelRotation), '@graph.graph: o.xTickLabelRotation must be a real number'); assert(ischar(o.xTickLabelAnchor), '@graph.graph: xTickLabelAnchor must be a string'); +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)]); + valid_legend_locations = ... {'south west','south east','north west','north east','outer north east'}; assert(any(strcmp(o.legendLocation, valid_legend_locations)), ... diff --git a/matlab/reports/@graph/writeGraphFile.m b/matlab/reports/@graph/writeGraphFile.m index 7521f116a757d608cfe3420546403462346eeaa0..40463c4ac2ddff88de9891b3235dba35371bdef5 100644 --- a/matlab/reports/@graph/writeGraphFile.m +++ b/matlab/reports/@graph/writeGraphFile.m @@ -141,9 +141,9 @@ 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, ['%%shading\n\\addplot[area legend,solid,fill=green,' ... + fprintf(fid, ['%%shading\n\\addplot[area legend,solid,fill=%s,' ... 'opacity=.2,draw=black,forget plot]\ntable[row sep=crcr]{\nx y\\\\\n%d %d\\\\\n%d %d\\\\\n%d %d\\\\\n%d %d\\\\\n};\n'], ... - x1, ymin, x1, ymax, x2, ymax, x2, ymin); + o.shadeColor, x1, ymin, x1, ymax, x2, ymax, x2, ymin); end for i=1:ne