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{`!'} ...@@ -8240,7 +8240,7 @@ command. Default: @code{`!'}
@end table @end table
@end defmethod @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}. Adds a @code{Graph} to a @code{Section}.
@optionshead @optionshead
@table @code @table @code
...@@ -8309,6 +8309,10 @@ The y-axis label. Default: @code{none} ...@@ -8309,6 +8309,10 @@ The y-axis label. Default: @code{none}
@item xrange, @code{dynDates} @item xrange, @code{dynDates}
The boundary on the x-axis to display in the graph. Default: all 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} @item yrange, @code{NUMERICAL_VECTOR}
The boundary on the y-axis to display in the graph, represented as a 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 @code{NUMERICAL_VECTOR} of size @math{2}, with the first entry less
......
...@@ -98,15 +98,19 @@ if ~isempty(o.shade) ...@@ -98,15 +98,19 @@ if ~isempty(o.shade)
set(gca, 'children', children); set(gca, 'children', children);
end end
xticks = get(gca, 'XTick'); if isempty(o.xTickLabels)
xTickLabels = cell(1, length(xticks)); xticks = get(gca, 'XTick');
for i=1:length(xticks) xTickLabels = cell(1, length(xticks));
if xticks(i) >= x(1) && ... for i=1:length(xticks)
xticks(i) <= x(end) if xticks(i) >= x(1) && ...
xTickLabels{i} = xlabels{xticks(i)}; xticks(i) <= x(end)
else xTickLabels{i} = xlabels{xticks(i)};
xTickLabels{i} = ''; else
xTickLabels{i} = '';
end
end end
else
xTickLabels = o.xTickLabels;
end end
set(gca, 'XTickLabel', xTickLabels); set(gca, 'XTickLabel', xTickLabels);
......
...@@ -60,6 +60,7 @@ o.legendFontSize = 8; ...@@ -60,6 +60,7 @@ o.legendFontSize = 8;
o.showZeroline = false; o.showZeroline = false;
o.graphSize = []; o.graphSize = [];
o.xTickLabels = {};
if nargin == 1 if nargin == 1
assert(isa(varargin{1}, 'graph'),['@graph.graph: with one arg you ' ... assert(isa(varargin{1}, 'graph'),['@graph.graph: with one arg you ' ...
...@@ -132,7 +133,8 @@ assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ['@graph.graph: ' ... ...@@ -132,7 +133,8 @@ assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ['@graph.graph: ' ...
assert(isempty(o.graphSize) || ((isfloat(o.graphSize) && length(o.graphSize) == 2)),... assert(isempty(o.graphSize) || ((isfloat(o.graphSize) && length(o.graphSize) == 2)),...
['@graph.graph: graphSize is specified as an array with two float ' ... ['@graph.graph: graphSize is specified as an array with two float ' ...
'entries, [width height]']); '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 % using o.seriesToUse, create series objects and put them in o.seriesElements
if ~isempty(o.data) if ~isempty(o.data)
if isempty(o.seriesToUse) 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