Commit 82e45f67 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

reporting: @graph: new option xTickLabels

parent a961069a
......@@ -8240,7 +8240,7 @@ command. Default: @code{`!'}
@end table
@end defmethod
@defmethod Report addGraph data, figname, graphSize, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, seriesToUse, shade, shadeColor, shadeOpacity, title, xlabel, ylabel, xrange, yrange, showZeroline
@defmethod Report addGraph data, figname, graphSize, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, seriesToUse, shade, shadeColor, shadeOpacity, title, xlabel, ylabel, xrange, xTickLabels, yrange, showZeroline
Adds a @code{Graph} to a @code{Section}.
@optionshead
@table @code
......@@ -8309,6 +8309,10 @@ The y-axis label. Default: @code{none}
@item xrange, @code{dynDates}
The boundary on the x-axis to display in the graph. Default: all
@item xTickLabels, @code{CELL_ARRAY_STRINGS}
The labels to use for the xticks in the graph. Default: the dates of
the @code{dynSeries}
@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
......
......@@ -98,15 +98,19 @@ if ~isempty(o.shade)
set(gca, 'children', children);
end
xticks = get(gca, 'XTick');
xTickLabels = cell(1, length(xticks));
for i=1:length(xticks)
if xticks(i) >= x(1) && ...
xticks(i) <= x(end)
xTickLabels{i} = xlabels{xticks(i)};
else
xTickLabels{i} = '';
if isempty(o.xTickLabels)
xticks = get(gca, 'XTick');
xTickLabels = cell(1, length(xticks));
for i=1:length(xticks)
if xticks(i) >= x(1) && ...
xticks(i) <= x(end)
xTickLabels{i} = xlabels{xticks(i)};
else
xTickLabels{i} = '';
end
end
else
xTickLabels = o.xTickLabels;
end
set(gca, 'XTickLabel', xTickLabels);
......
......@@ -60,6 +60,7 @@ o.legendFontSize = 8;
o.showZeroline = false;
o.graphSize = [];
o.xTickLabels = {};
if nargin == 1
assert(isa(varargin{1}, 'graph'),['@graph.graph: with one arg you ' ...
......@@ -132,7 +133,8 @@ assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ['@graph.graph: ' ...
assert(isempty(o.graphSize) || ((isfloat(o.graphSize) && length(o.graphSize) == 2)),...
['@graph.graph: graphSize is specified as an array with two float ' ...
'entries, [width height]']);
assert(iscellstr(o.xTickLabels), ...
'@graph.graph: xTickLabels must be a cell array of strings');
% using o.seriesToUse, create series objects and put them in o.seriesElements
if ~isempty(o.data)
if isempty(o.seriesToUse)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment