From 9258aecba0328c4803332a86eb384eb4491af28a Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Mon, 9 Jun 2014 12:16:54 +0200 Subject: [PATCH] reporting: add options to control y axis label --- doc/dynare.texi | 13 ++++++++++++- matlab/reports/@graph/graph.m | 7 +++++++ matlab/reports/@graph/writeGraphFile.m | 10 +++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index da47c7a88..9bca805c8 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -11163,7 +11163,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, 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 Adds a @code{Graph} to a @code{Section}. @optionshead @table @code @@ -11303,6 +11303,17 @@ 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 than the second entry. Default: all +@item yTickLabelFixed, @code{BOOLEAN} +Round the y tick labels to a fixed number of decimal places, given by +@ref{yTickLabelPrecision}. Default: @code{true} + +@anchor{yTickLabelPrecision} +@item yTickLabelPrecision, @code{INTEGER} +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} + @item showZeroline, @code{BOOLEAN} Display a solid black line at @math{y = 0}. Default: @code{false} diff --git a/matlab/reports/@graph/graph.m b/matlab/reports/@graph/graph.m index 687304397..2d9f97560 100644 --- a/matlab/reports/@graph/graph.m +++ b/matlab/reports/@graph/graph.m @@ -69,6 +69,10 @@ o.xTickLabels = {}; o.xTickLabelRotation = 0; o.xTickLabelAnchor = 'east'; +o.yTickLabelPrecision = 0; +o.yTickLabelFixed = true; +o.yTickLabelZeroFill = true; + o.width = 6; o.height = 4.5; @@ -125,6 +129,9 @@ assert(isfloat(o.width), '@graph.graph: o.width must be a real number'); 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'); +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', ... diff --git a/matlab/reports/@graph/writeGraphFile.m b/matlab/reports/@graph/writeGraphFile.m index 2b706a8fe..8aaa7de24 100644 --- a/matlab/reports/@graph/writeGraphFile.m +++ b/matlab/reports/@graph/writeGraphFile.m @@ -103,7 +103,15 @@ for i = 1:xlen fprintf(fid,','); end end -fprintf(fid, '},\nx tick label style={rotate=%f', o.xTickLabelRotation); +fprintf(fid, '},\ny tick label style={\n/pgf/number format/.cd,\n'); +if o.yTickLabelFixed + fprintf(fid, 'fixed,\n'); +end +if o.yTickLabelZeroFill + fprintf(fid, 'zerofill,\n'); +end +fprintf(fid, 'precision=%d,\n/tikz/.cd\n},\n', o.yTickLabelPrecision); +fprintf(fid, 'x tick label style={rotate=%f', o.xTickLabelRotation); if o.xTickLabelRotation ~= 0 fprintf(fid, ',anchor=%s', o.xTickLabelAnchor); end