reporting: add options xAxisTight and yAxisTight

time-shift
Houtan Bastani 2014-02-13 17:01:34 +01:00
parent 2916fc49b9
commit eeedda5e2d
4 changed files with 33 additions and 11 deletions

View File

@ -10704,7 +10704,7 @@ command. Default: @code{`!'}
@end table
@end defmethod
@defmethod Report addGraph data, figname, figDirName, graphSize, height, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, seriesToUse, shade, shadeColor, shadeOpacity, title, width, xlabel, ylabel, xrange, xTicks, xTickLabels, xTickLabelAnchor, xTickLabelRotation, yrange, showZeroline
@defmethod Report addGraph data, figname, figDirName, graphSize, height, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, seriesToUse, shade, shadeColor, shadeOpacity, title, width, xlabel, ylabel, xAxisTight, xrange, xTicks, xTickLabels, xTickLabelAnchor, xTickLabelRotation, yAxisTight, yrange, showZeroline
Adds a @code{Graph} to a @code{Section}.
@optionshead
@table @code
@ -10779,6 +10779,10 @@ The x-axis label. Default: @code{none}
@item ylabel, @code{STRING}
The y-axis label. Default: @code{none}
@item xAxisTight, @code{BOOLEAN}
Use a tight x axis. If false, uses pgfplots @code{enlarge x limits} to
choose appropriate axis size. Default: @code{true}
@item xrange, @code{dates}
The boundary on the x-axis to display in the graph. Default: all
@ -10799,6 +10803,10 @@ 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}
@item yAxisTight, @code{BOOLEAN}
Use a tight y axis. If false, uses pgfplots @code{enlarge y limits} to
choose appropriate axis size. Default: @code{false}
@item yrange, @code{NUMERICAL_VECTOR}
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

View File

@ -44,7 +44,9 @@ o.figname = '';
o.data = '';
o.seriesToUse = '';
o.xrange = '';
o.xAxisTight = true;
o.yrange = '';
o.yAxisTight = false;
o.shade = '';
o.shadeColor = 'green';
@ -101,6 +103,8 @@ assert(ischar(o.ylabel), '@graph.graph: ylabel file must be a string');
assert(ischar(o.figname), '@graph.graph: figname must be a string');
assert(ischar(o.figDirName), '@graph.graph: figDirName must be a string');
assert(islogical(o.showGrid), '@graph.graph: showGrid must be either true or false');
assert(islogical(o.xAxisTight), '@graph.graph: xAxisTight must be either true or false');
assert(islogical(o.yAxisTight), '@graph.graph: yAxisTight must be either true or false');
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');

View File

@ -85,12 +85,20 @@ fprintf(fid, ['},\n',...
'width=%fin,\n'...
'height=%fin,\n'...
'scale only axis,\n'...
'xmin=1,\n'...
'xmax=%d,\n'...
'axis lines=box,\n'], o.width, o.height, dd.ndat);
'axis lines=box,\n'], o.width, o.height);
if o.xAxisTight
fprintf(fid, 'enlarge x limits=false,\n');
else
fprintf(fid, 'enlarge x limits=true,\n');
end
if isempty(o.yrange)
fprintf(fid, 'enlarge y limits=true,\n');
if o.yAxisTight
fprintf(fid, 'enlarge y limits=false,\n');
else
fprintf(fid, 'enlarge y limits=true,\n');
end
else
fprintf(fid, 'ymin=%f,\nymax=%f,\n',o.yrange(1),o.yrange(2));
end
@ -139,10 +147,10 @@ if ~isempty(o.shade)
date2string(o.shade(1)) ' or ' date2string(o.shade(end)) ' is not in the date ' ...
'range of data selected.']);
fprintf(fid,['\\begin{pgfonlayer}{background}\n\\fill[%s!%f]\n(axis ' ...
'cs:%d,\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ...
'cs:%d,\\pgfkeysvalueof{/pgfplots/ymax});\n' ...
'\\end{pgfonlayer}\n'], ...
o.shadeColor, o.shadeOpacity, x1, x2);
'cs:%f,\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ...
'cs:\\pgfkeysvalueof{/pgfplots/xmax},\\pgfkeysvalueof{/' ...
'pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
o.shadeColor, o.shadeOpacity,x1);
end
fprintf(fid, '\\end{axis}\n\\end{tikzpicture}\n');

View File

@ -117,7 +117,7 @@ rep = AnnualTable(rep, db_a, dc_a, 'Y_', larange);
for i=1:length(shortNames)
rep = rep.addPage('title', {'Jan1 vs Jan2', longNames{i}}, ...
'titleFormat', {'\large\bfseries', '\large'});
rep = rep.addSection('cols', 2);
rep = rep.addSection('cols', 5);
rep = CountryGraphPage(rep, shortNames{i}, db_q, dc_q, prange, srange);
rep = rep.addPage('title', 'Jan1 vs Jan2', ...
@ -223,7 +223,9 @@ rep = rep.addGraph('title', 'World Real Food Price', ...
'shade', srange, ...
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
'xTickLabelRotation', 0);
'xTickLabelRotation', 0,...
'xAxisTight',false,...
'yAxisTight',true);
rep = rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...
'graphLineColor', 'blue', ...
'graphLineWidth', 1.5);