reporting: add legendAt option. closes #810
parent
544e10fc29
commit
beb3fd1534
|
@ -11458,7 +11458,7 @@ command. Default: @code{`!'}
|
|||
@end defmethod
|
||||
|
||||
@anchor{addGraph}
|
||||
@defmethod Report addGraph axisShape, data, graphDirName, graphName, graphSize, height, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, miscTikzAxisOptions, miscTikzPictureOptions, seriesToUse, shade, shadeColor, shadeOpacity, tickFontSize, title, titleFontSize, titleFormat, width, writeCSV, xlabel, ylabel, xAxisTight, xrange, xTicks, xTickLabels, xTickLabelAnchor, xTickLabelRotation, yAxisTight, yTickLabelFixed, yTickLabelPrecision, yTickLabelScaled, yTickLabelZeroFill, yrange, showZeroline, zeroLineColor
|
||||
@defmethod Report addGraph axisShape, data, graphDirName, graphName, graphSize, height, showGrid, showLegend, legendAt, showLegendBox, legendLocation, legendOrientation, legendFontSize, miscTikzAxisOptions, miscTikzPictureOptions, seriesToUse, shade, shadeColor, shadeOpacity, tickFontSize, title, titleFontSize, titleFormat, width, writeCSV, xlabel, ylabel, xAxisTight, xrange, xTicks, xTickLabels, xTickLabelAnchor, xTickLabelRotation, yAxisTight, yTickLabelFixed, yTickLabelPrecision, yTickLabelScaled, yTickLabelZeroFill, yrange, showZeroline, zeroLineColor
|
||||
Adds a @code{Graph} to a @code{Section}.
|
||||
@optionshead
|
||||
@table @code
|
||||
|
@ -11497,10 +11497,16 @@ Whether or not to display the legend. NB: Unless you use the
|
|||
@code{tex} name associated with the @code{dseries}. You can modify this
|
||||
@code{tex} name by using @ref{tex_rename}. Default: @code{false}
|
||||
|
||||
@item legendAt, @code{NUMERICAL_VECTOR}
|
||||
The coordinates for the legend location. If this option is passed, it
|
||||
overrides the @ref{legendLocation} option. Must be of size 2. Default:
|
||||
@code{empty}.
|
||||
|
||||
@item showLegendBox, @code{BOOLEAN}
|
||||
Whether or not to display a box around the legend. Default:
|
||||
@code{false}
|
||||
|
||||
@anchor{legendLocation}
|
||||
@item legendLocation, @code{`south west'} | @code{`south east'} | @code{`north west'} | @code{`north east'} | @code{`outer north east'}
|
||||
Where to place the legend in the graph. Default: @code{`south east'}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ o.shadeOpacity = 20;
|
|||
o.showGrid = true;
|
||||
|
||||
o.showLegend = false;
|
||||
o.legendAt = [];
|
||||
o.showLegendBox = false;
|
||||
o.legendLocation = 'south east';
|
||||
o.legendOrientation = 'horizontal';
|
||||
|
@ -128,6 +129,8 @@ assert(islogical(o.showGrid), '@graph.graph: showGrid must be either true or fal
|
|||
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(isempty(o.legendAt) || (isfloat(o.legendAt) && length(o.legendAt)==2), ...
|
||||
'@graph.graph: legendAt must be a double array of size two');
|
||||
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(isfloat(o.shadeOpacity) && length(o.shadeOpacity)==1 && ...
|
||||
|
|
|
@ -169,7 +169,11 @@ if o.showLegend
|
|||
if strcmp(o.legendOrientation, 'horizontal')
|
||||
fprintf(fid,'legend columns=-1,');
|
||||
end
|
||||
fprintf(fid, '},\nlegend pos=%s,\n', o.legendLocation);
|
||||
if isempty(o.legendAt)
|
||||
fprintf(fid, '},\nlegend pos=%s,\n', o.legendLocation);
|
||||
else
|
||||
fprintf(fid, 'at={(%f,%f)}},\n',o.legendAt(1),o.legendAt(2));
|
||||
end
|
||||
end
|
||||
|
||||
fprintf(fid, 'tick label style={font=\\%s},\n', o.tickFontSize);
|
||||
|
|
|
@ -181,7 +181,8 @@ rep = rep.addGraph('title', 'World Real Food Price Index', ...
|
|||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0, ...
|
||||
'showLegend', true);
|
||||
'showLegend', true, ...
|
||||
'legendAt', [.5,.5]);
|
||||
rep = rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
|
||||
'graphBar', true, ...
|
||||
'graphBarColor', 'green', ...
|
||||
|
|
Loading…
Reference in New Issue