reporting: change xTickLabels default to be first date, last date, and, if passed, the first date of the shade region. Accordingly, change the default of the tick rotation to be 0.
parent
fee1f9442f
commit
5899a19e79
|
@ -10836,6 +10836,7 @@ The names of the series contained in the @code{dseries} provided to
|
|||
the @ref{data} option. If empty, use all series provided to
|
||||
@ref{data} option. Default: @code{empty}
|
||||
|
||||
@anchor{shade}
|
||||
@item shade, @code{dates}
|
||||
The date range showing the portion of the graph that should be
|
||||
shaded. Default: @code{none}
|
||||
|
@ -10876,18 +10877,21 @@ The boundary on the x-axis to display in the graph. Default: all
|
|||
@item xTicks, @code{NUMERICAL_VECTOR}
|
||||
Used only in conjunction with @ref{xTickLabels}, this option denotes
|
||||
the numerical position of the label along the x-axis. The positions
|
||||
begin at @math{1}. Default: set by Matlab/Octave.
|
||||
begin at @math{1}. Default: the indices associated with the first and
|
||||
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}
|
||||
The labels to be mapped to the ticks provided by
|
||||
@ref{xTicks}. Default: the dates of the @code{dseries}
|
||||
@ref{xTicks}. Default: the first and last dates of the @code{dseries}
|
||||
and, if passed, the date first date of the @ref{shade} option.
|
||||
|
||||
@item xTickLabelAnchor, @code{STRING}
|
||||
Where to anchor the x tick label. Default: @code{`south'}
|
||||
|
||||
@item xTickLabelRotation, @code{DOUBLE}
|
||||
The amount to rotate the x tick labels by. Default: @code{45}
|
||||
The amount to rotate the x tick labels by. Default: @code{0}
|
||||
|
||||
@item yAxisTight, @code{BOOLEAN}
|
||||
Use a tight y axis. If false, uses pgfplots @code{enlarge y limits} to
|
||||
|
|
|
@ -66,7 +66,7 @@ o.showZeroline = false;
|
|||
o.graphSize = [];
|
||||
o.xTicks = [];
|
||||
o.xTickLabels = {};
|
||||
o.xTickLabelRotation = 45;
|
||||
o.xTickLabelRotation = 0;
|
||||
o.xTickLabelAnchor = 'east';
|
||||
|
||||
o.width = 6;
|
||||
|
|
|
@ -56,12 +56,19 @@ if isempty(o.xrange)
|
|||
else
|
||||
dd = o.xrange;
|
||||
end
|
||||
stringsdd = strings(dd);
|
||||
|
||||
fprintf(fid, '\\begin{axis}[%%\n');
|
||||
% set tick labels
|
||||
if isempty(o.xTickLabels)
|
||||
x = 1:1:dd.ndat;
|
||||
xTickLabels = strings(dd);
|
||||
if ~isempty(o.shade)
|
||||
x1 = find(strcmpi(date2string(o.shade(1)), stringsdd));
|
||||
x = [1 x1 dd.ndat];
|
||||
xTickLabels = [stringsdd(1) stringsdd(x1) stringsdd(end)];
|
||||
else
|
||||
x = [1 dd.ndat];
|
||||
xTickLabels = [stringsdd(1) stringsdd(end)];
|
||||
end
|
||||
fprintf(fid, 'xminorticks=true,\nyminorticks=true,\n');
|
||||
else
|
||||
fprintf(fid,'minor xtick,\n');
|
||||
|
@ -69,11 +76,12 @@ else
|
|||
xTickLabels = o.xTickLabels;
|
||||
end
|
||||
fprintf(fid, 'xticklabels={');
|
||||
for i = 1:length(x)
|
||||
xlen = length(x);
|
||||
for i = 1:xlen
|
||||
fprintf(fid,'%s,',lower(xTickLabels{i}));
|
||||
end
|
||||
fprintf(fid, '},\nxtick={');
|
||||
for i = 1:length(x)
|
||||
for i = 1:xlen
|
||||
fprintf(fid, '%d',x(i));
|
||||
if i ~= length(x)
|
||||
fprintf(fid,',');
|
||||
|
@ -159,9 +167,8 @@ for i=1:ne
|
|||
end
|
||||
|
||||
if ~isempty(o.shade)
|
||||
xTickLabels = strings(dd);
|
||||
x1 = find(strcmpi(date2string(o.shade(1)), xTickLabels));
|
||||
x2 = find(strcmpi(date2string(o.shade(end)), xTickLabels));
|
||||
x1 = find(strcmpi(date2string(o.shade(1)), stringsdd));
|
||||
x2 = find(strcmpi(date2string(o.shade(end)), stringsdd));
|
||||
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.']);
|
||||
|
|
|
@ -239,8 +239,6 @@ rep = rep.addGraph('title', 'Equilibrium World Real Food Price', ...
|
|||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'showLegend', true, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0);
|
||||
rep = rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
|
|
Loading…
Reference in New Issue