diff --git a/doc/dynare.texi b/doc/dynare.texi index b371d9f80fedbace0b244918eba19d4cb6b9f3d2..7fe9df42db6fd3e661bea4a72ddf884905bc4db2 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -10882,7 +10882,7 @@ last dates of the @code{dseries} and, if passed, the index associated with the first date of the @ref{shade} option. @anchor{xTickLabels} -@item xTickLabels, @code{CELL_ARRAY_STRINGS} +@item xTickLabels, @code{CELL_ARRAY_STRINGS} | `ALL' The labels to be mapped to the ticks provided by @ref{xTicks}. Default: the first and last dates of the @code{dseries} and, if passed, the date first date of the @ref{shade} option. diff --git a/matlab/reports/@graph/graph.m b/matlab/reports/@graph/graph.m index 7b710e3fc2a35e707a655c2284e9b97a5203b1aa..e79b402f6049b0e4b6b49787174b7f78b8451b49 100644 --- a/matlab/reports/@graph/graph.m +++ b/matlab/reports/@graph/graph.m @@ -161,10 +161,13 @@ assert(isempty(o.graphSize) || ((isfloat(o.graphSize) && length(o.graphSize) == 'entries, [width height]']); assert(isempty(o.xTicks) || isfloat(o.xTicks),... '@graph.graph: xTicks must be a numerical array'); -assert(iscellstr(o.xTickLabels), ... - '@graph.graph: xTickLabels must be a cell array of strings'); +assert(iscellstr(o.xTickLabels) || (ischar(o.xTickLabels) && strcmpi(o.xTickLabels, 'ALL')), ... + ['@graph.graph: xTickLabels must be a cell array of strings or ' ... + 'equivalent to the string ''ALL''']); if ~isempty(o.xTickLabels) - assert(~isempty(o.xTicks), '@graph.graph: if you set xTickLabels, you must set xTicks'); + assert((ischar(o.xTickLabels) && strcmpi(o.xTickLabels, 'ALL')) || ... + ~isempty(o.xTicks), ['@graph.graph: if you set xTickLabels and ' ... + 'it''s not equal to ''ALL'', you must set xTicks']); end if ~isempty(o.xTicks) assert(~isempty(o.xTickLabels), '@graph.graph: if you set xTicks, you must set xTickLabels'); diff --git a/matlab/reports/@graph/writeGraphFile.m b/matlab/reports/@graph/writeGraphFile.m index db44025b38b873c815dcd487df1d8dbd5ec3ab80..56d458f6c487c0401d53e6b9a3aeb1f12b348334 100644 --- a/matlab/reports/@graph/writeGraphFile.m +++ b/matlab/reports/@graph/writeGraphFile.m @@ -56,11 +56,11 @@ if isempty(o.xrange) else dd = o.xrange; end -stringsdd = strings(dd); fprintf(fid, '\\begin{axis}[%%\n'); % set tick labels if isempty(o.xTickLabels) + stringsdd = strings(dd); if ~isempty(o.shade) x1 = find(strcmpi(date2string(o.shade(1)), stringsdd)); x = [1 x1 dd.ndat]; @@ -70,10 +70,13 @@ if isempty(o.xTickLabels) xTickLabels = [stringsdd(1) stringsdd(end)]; end fprintf(fid, 'xminorticks=true,\nyminorticks=true,\n'); -else +elseif iscell(o.xTickLabels) fprintf(fid,'minor xtick,\n'); x = o.xTicks; xTickLabels = o.xTickLabels; +else + x = [1:dd.ndat]; + xTickLabels = strings(dd); end fprintf(fid, 'xticklabels={'); xlen = length(x); @@ -167,6 +170,7 @@ for i=1:ne end if ~isempty(o.shade) + stringsdd = strings(dd); x1 = find(strcmpi(date2string(o.shade(1)), stringsdd)); x2 = find(strcmpi(date2string(o.shade(end)), stringsdd)); assert(~isempty(x1) && ~isempty(x2), ['@graph.writeGraphFile: either ' ... diff --git a/tests/reporting/runDynareReport.m b/tests/reporting/runDynareReport.m index 4bdd4ffc754be0dc88ebd772919901d2cb9c1b6d..684a320fdc81a6c36471925f5b8d6ba021797f6d 100644 --- a/tests/reporting/runDynareReport.m +++ b/tests/reporting/runDynareReport.m @@ -222,9 +222,8 @@ rep = rep.addSeries('data', dc_q{'LRPOIL_BAR_WORLD'}, ... rep = rep.addGraph('title', 'World Real Food Price', ... 'xrange', prange, ... 'shade', srange, ... - 'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ... - 'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},... - 'xTickLabelRotation', 0,... + 'xTickLabels','ALL',... + 'xTickLabelRotation', 45,... 'xAxisTight',false,... 'yAxisTight',true); rep = rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...