reporting: make option names uniform by removing underscores to conform with Matlab style options

Conflicts:
	matlab/reports/@series/series.m
	matlab/reports/@series/write.m
time-shift
Houtan Bastani 2013-05-13 17:06:48 +02:00
parent bd11ea293e
commit 9fa99b5337
11 changed files with 90 additions and 90 deletions

View File

@ -87,8 +87,8 @@ if ~isempty(o.shade)
% From ShadePlotForEmpahsis (Matlab Exchange)
% use patch bc area doesn't work with matlab2tikz
sh = patch([repmat(x1, 1, 2) repmat(x2, 1, 2)], ...
[yrange fliplr(yrange)], o.shade_color, ...
'facealpha', o.shade_opacity);
[yrange fliplr(yrange)], o.shadeColor, ...
'facealpha', o.shadeOpacity);
children = get(gca, 'children');
children = [children(2:end); sh];
set(gca, 'children', children);
@ -108,9 +108,9 @@ set(gca, 'XTickLabel', xTickLabels);
if o.showLegend
lh = legend(line_handles, o.seriesElements.getTexNames(), ...
'orientation', o.legend_orientation, ...
'location', o.legend_location);
set(lh, 'FontSize', o.legend_font_size);
'orientation', o.legendOrientation, ...
'location', o.legendLocation);
set(lh, 'FontSize', o.legendFontSize);
set(lh, 'interpreter', 'latex');
if ~o.showLegendBox
legend('boxoff');

View File

@ -44,21 +44,21 @@ o.footnote = '';
o.figname = '';
o.data = '';
o.seriestouse = '';
o.seriesToUse = '';
o.xrange = '';
o.yrange = '';
o.shade = '';
o.shade_color = [0 1 0];
o.shade_opacity = .2;
o.shadeColor = [0 1 0];
o.shadeOpacity = .2;
o.showGrid = true;
o.showLegend = false;
o.showLegendBox = false;
o.legend_location = 'SouthEast';
o.legend_orientation = 'horizontal';
o.legend_font_size = 8;
o.legendLocation = 'SouthEast';
o.legendOrientation = 'horizontal';
o.legendFontSize = 8;
o.zeroline = false;
@ -98,11 +98,11 @@ assert(ischar(o.figname), '@graph.graph: figname must be a string');
assert(islogical(o.showGrid), '@graph.graph: showGrid 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(isint(o.legend_font_size), '@graph.graph: legend_font_size must be an integer');
assert(isint(o.legendFontSize), '@graph.graph: legendFontSize must be an integer');
assert(islogical(o.zeroline), '@graph.graph: zeroline must be either true or false');
assert(isfloat(o.shade_opacity) && length(o.shade_opacity)==1 && ...
o.shade_opacity >= 0 && o.shade_opacity <= 1, ...
'@graph.graph: o.shade_opacity must be a real in [0 1]');
assert(isfloat(o.shadeOpacity) && length(o.shadeOpacity)==1 && ...
o.shadeOpacity >= 0 && o.shadeOpacity <= 1, ...
'@graph.graph: o.shadeOpacity must be a real in [0 1]');
valid_legend_locations = ...
{'North', 'South', 'East', 'West', ...
'NorthEast', 'SouthEast', 'NorthWest', 'SouthWest', ...
@ -110,12 +110,12 @@ valid_legend_locations = ...
'NorthEastOutside', 'SouthEastOutside', 'NorthWestOutside', 'SouthWestOutside', ...
'Best', 'BestOutside', ...
};
assert(any(strcmp(o.legend_location, valid_legend_locations)), ...
['@graph.graph: legend_location must be one of ' strjoin(valid_legend_locations, ' ')]);
assert(any(strcmp(o.legendLocation, valid_legend_locations)), ...
['@graph.graph: legendLocation must be one of ' strjoin(valid_legend_locations, ' ')]);
valid_legend_orientations = {'vertical', 'horizontal'};
assert(any(strcmp(o.legend_orientation, valid_legend_orientations)), ...
['@graph.graph: legend_orientation must be one of ' strjoin(valid_legend_orientations, ' ')]);
assert(any(strcmp(o.legendOrientation, valid_legend_orientations)), ...
['@graph.graph: legendOrientation must be one of ' strjoin(valid_legend_orientations, ' ')]);
assert(isempty(o.shade) || (isa(o.shade, 'dynDates') && o.shade.ndat >= 2), ...
['@graph.graph: shade is specified as a dynDates range, e.g. ' ...
@ -129,22 +129,22 @@ assert(isempty(o.yrange) || (isfloat(o.yrange) && length(o.yrange) == 2 && ...
'the lower bound and upper bound.']);
assert(isempty(o.data) || isa(o.data, 'dynSeries'), ['@graph.graph: data must ' ...
'be a dynSeries']);
assert(isempty(o.seriestouse) || iscellstr(o.seriestouse), ['@graph.graph: ' ...
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ['@graph.graph: ' ...
'series to use must be a cell array of string(s)']);
% 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.seriestouse)
if isempty(o.seriesToUse)
for i=1:o.data.vobs
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.data.name{i}});
end
else
for i=1:length(o.seriestouse)
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriestouse{i}});
for i=1:length(o.seriesToUse)
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriesToUse{i}});
end
end
end
o = rmfield(o, 'seriestouse');
o = rmfield(o, 'seriesToUse');
o = rmfield(o, 'data');
% Create graph object

View File

@ -32,7 +32,7 @@ function o = page(varargin)
o = struct;
o.paper = '';
o.title = {};
o.title_format = {};
o.titleFormat = {};
o.orientation = '';
o.footnote = {};
o.sections = sections();
@ -67,15 +67,15 @@ end
if ischar(o.title)
o.title = {o.title};
end
if ischar(o.title_format)
o.title_format = {o.title_format};
if ischar(o.titleFormat)
o.titleFormat = {o.titleFormat};
end
assert(iscellstr(o.title), ...
'@page.page: title must be a cell array of strings');
assert(iscellstr(o.title_format), ...
'@page.page: title_format must be a cell array of strings');
assert(length(o.title)==length(o.title_format), ...
'@page.page: title and title_format must be of the same length');
assert(iscellstr(o.titleFormat), ...
'@page.page: titleFormat must be a cell array of strings');
assert(length(o.title)==length(o.titleFormat), ...
'@page.page: title and titleFormat must be of the same length');
valid_paper = {'a4', 'letter'};
assert(any(strcmp(o.paper, valid_paper)), ...

View File

@ -43,7 +43,7 @@ fprintf(fid,'\n');
fprintf(fid, '\\begin{tabular}[t]{c}\n');
for i=1:length(o.title)
fprintf(fid,'\\multicolumn{1}{c}{%s %s}\\\\\n', o.title_format{i}, o.title{i});
fprintf(fid,'\\multicolumn{1}{c}{%s %s}\\\\\n', o.titleFormat{i}, o.title{i});
end
o.sections.write(fid);

View File

@ -36,7 +36,7 @@ o.title = '';
o.orientation = 'portrait';
o.paper = 'a4';
o.margin = 2.5;
o.margin_unit = 'cm';
o.marginUnit = 'cm';
o.pages = pages();
o.filename = 'report.tex';
o.config = '';
@ -79,8 +79,8 @@ assert(islogical(o.showDate), '@report.report: showDate must be either true or f
assert(isfloat(o.margin) && o.margin > 0, '@report.report: margin must be a float > 0.');
valid_margin_unit = {'cm', 'in'};
assert(any(strcmp(o.margin_unit, valid_margin_unit)), ...
['@report.report: margin_unit must be one of ' strjoin(valid_margin_unit, ' ')]);
assert(any(strcmp(o.marginUnit, valid_margin_unit)), ...
['@report.report: marginUnit must be one of ' strjoin(valid_margin_unit, ' ')]);
valid_paper = {'a4', 'letter'};
assert(any(strcmp(o.paper, valid_paper)), ...

View File

@ -36,7 +36,7 @@ end
fprintf(fid, '%% Report Object\n');
fprintf(fid, '\\documentclass[11pt]{article}\n');
fprintf(fid, '\\usepackage[%spaper,margin=%f%s', o.paper, o.margin, o.margin_unit);
fprintf(fid, '\\usepackage[%spaper,margin=%f%s', o.paper, o.margin, o.marginUnit);
if strcmpi(o.orientation, 'landscape')
fprintf(fid, ',landscape');
end

View File

@ -36,26 +36,26 @@ assert(~isempty(o.data) && isa(o.data, 'dynSeries'), ['@series.getLine: must ' .
% Line
assert(ischar(o.color), '@series.getLine: color must be a string');
valid_line_style = {'none', '-', '--', ':', '-.'};
assert(any(strcmp(o.line_style, valid_line_style)), ...
['@series.getLine: line_style must be one of ' strjoin(valid_line_style, ' ')]);
assert(isfloat(o.line_width), ['@series.getLine: line_width must be a ' ...
assert(any(strcmp(o.lineStyle, valid_line_style)), ...
['@series.getLine: lineStyle must be one of ' strjoin(valid_line_style, ' ')]);
assert(isfloat(o.lineWidth), ['@series.getLine: lineWidth must be a ' ...
'positive number']);
% Graph_Marker
valid_graph_marker = {'+', 'o', '*', '.', 'x', 's', 'square', 'd', 'diamond', ...
% GraphMarker
valid_graphMarker = {'+', 'o', '*', '.', 'x', 's', 'square', 'd', 'diamond', ...
'^', 'v', '>', '<', 'p', 'pentagram', 'h', 'hexagram', ...
'none'};
assert(isempty(o.graph_marker) || any(strcmp(o.graph_marker, valid_graph_marker)), ...
['@series.getLine: graph_marker must be one of ' strjoin(valid_graph_marker)]);
assert(isempty(o.graphMarker) || any(strcmp(o.graphMarker, valid_graphMarker)), ...
['@series.getLine: graphMarker must be one of ' strjoin(valid_graphMarker)]);
assert(ischar(o.graph_marker_edge_color), '@series.getLine: graph_marker_edge_color must be a string');
assert(ischar(o.graph_marker_face_color), '@series.getLine: graph_marker_face_color must be a string');
assert(isfloat(o.graph_marker_size), ['@series.getLine: graph_marker_size must be a ' ...
assert(ischar(o.graphMarkerEdgeColor), '@series.getLine: graphMarkerEdgeColor must be a string');
assert(ischar(o.graphMarkerFaceColor), '@series.getLine: graphMarkerFaceColor must be a string');
assert(isfloat(o.graphMarkerSize), ['@series.getLine: graphMarkerSize must be a ' ...
'positive number']);
% Marker & Line
assert(~(strcmp(o.line_style, 'none') && isempty(o.graph_marker)), ['@series.getLine: ' ...
'you must provide at least one of line_style and graph_marker']);
assert(~(strcmp(o.lineStyle, 'none') && isempty(o.graphMarker)), ['@series.getLine: ' ...
'you must provide at least one of lineStyle and graphMarker']);
% Validate xrange
assert(isempty(xrange) || isa(xrange, 'dynDates'));
@ -71,14 +71,14 @@ opt = {'XData', 1:length(ds.data)};
opt = {opt{:}, 'YData', ds.data};
opt = {opt{:}, 'Color', o.color};
opt = {opt{:}, 'LineStyle', o.line_style};
opt = {opt{:}, 'LineWidth', o.line_width};
opt = {opt{:}, 'LineStyle', o.lineStyle};
opt = {opt{:}, 'LineWidth', o.lineWidth};
if ~isempty(o.graph_marker)
opt = {opt{:}, 'Marker', o.graph_marker};
opt = {opt{:}, 'MarkerSize', o.graph_marker_size};
opt = {opt{:}, 'MarkerEdgeColor', o.graph_marker_edge_color};
opt = {opt{:}, 'MarkerFaceColor', o.graph_marker_face_color};
if ~isempty(o.graphMarker)
opt = {opt{:}, 'Marker', o.graphMarker};
opt = {opt{:}, 'MarkerSize', o.graphMarkerSize};
opt = {opt{:}, 'MarkerEdgeColor', o.graphMarkerEdgeColor};
opt = {opt{:}, 'MarkerFaceColor', o.graphMarkerFaceColor};
end
h = line(opt{:});

View File

@ -36,19 +36,19 @@ o = struct;
o.data = '';
o.color = 'k';
o.line_style = '-';
o.line_width = 0.5;
o.lineStyle = '-';
o.lineWidth = 0.5;
o.graph_marker = '';
o.graph_marker_edge_color = 'auto';
o.graph_marker_face_color = 'auto';
o.graph_marker_size = 6;
o.graphMarker = '';
o.graphMarkerEdgeColor = 'auto';
o.graphMarkerFaceColor = 'auto';
o.graphMarkerSize = 6;
o.showTableMarkers = false;
o.table_neg_color = 'red';
o.table_pos_color = 'blue';
o.tableNegColor = 'red';
o.tablePosColor = 'blue';
o.table_align_right = false;
o.tableAlignRight = false;
if nargin == 1
assert(isa(varargin{1}, 'series'),['@series.series: with one arg you ' ...

View File

@ -40,21 +40,21 @@ assert(~isempty(o.data) && isa(o.data, 'dynSeries'), ...
'@series.write: must provide data as a dynSeries');
assert(ischar(o.color), '@series.write: color must be a string');
assert(ischar(o.table_neg_color), '@series.write: table_neg_color must be a string');
assert(ischar(o.table_pos_color), '@series.write: table_pos_color must be a string');
assert(ischar(o.tableNegColor), '@series.write: tableNegColor must be a string');
assert(ischar(o.tablePosColor), '@series.write: tablePosColor must be a string');
assert(islogical(o.showTableMarkers), '@series.write: showTableMarkers must be a string');
assert(islogical(o.table_align_right), '@series.write: table_align_right must be a string');
assert(islogical(o.tableAlignRight), '@series.write: tableAlignRight must be a string');
%% Write Output
dataString = ['%.' num2str(precision) 'f'];
precision = 10^precision;
fprintf(fid, '%% Table Row (series)\n');
if o.table_align_right
if o.tableAlignRight
fprintf(fid, '\\multicolumn{1}{r}{');
end
fprintf(fid, '%s', o.data.tex{:});
if o.table_align_right
if o.tableAlignRight
fprintf(fid, '}');
end
data = o.data(dates);
@ -65,9 +65,9 @@ for i=1:size(data,1)
fprintf(fid, ' &');
if o.showTableMarkers
if thisCellData < 0
fprintf(fid, '\\color{%s}', o.table_neg_color);
fprintf(fid, '\\color{%s}', o.tableNegColor);
elseif thisCellData > 0
fprintf(fid, '\\color{%s}', o.table_pos_color);
fprintf(fid, '\\color{%s}', o.tablePosColor);
end
fprintf(fid, '[');
end

View File

@ -34,16 +34,16 @@ o = struct;
o.seriesElements = seriesElements();
o.title = '';
o.title_size = 'large';
o.titleSize = 'large';
o.footnote = '';
o.config = '';
o.hlines = false;
o.vlines = false;
o.vline_after = '';
o.vlineAfter = '';
o.data = '';
o.seriestouse = '';
o.seriesToUse = '';
o.range = {};
o.precision = 1;
@ -86,31 +86,31 @@ assert(isempty(o.range) || (isa(o.range, 'dynDates') && o.range.ndat >= 2), ...
'''dynDates(''1999q1''):dynDates(''1999q3'')''.']);
assert(isempty(o.data) || isa(o.data, 'dynSeries'), ...
'@table.table: data must be a dynSeries');
assert(isempty(o.seriestouse) || iscellstr(o.seriestouse), ...
'@table.table: seriestouse must be a cell array of string(s)');
assert(isempty(o.vline_after) || isa(o.vline_after, 'dynDate'), ...
'@table.table: vline_after must be a dynDate');
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ...
'@table.table: seriesToUse must be a cell array of string(s)');
assert(isempty(o.vlineAfter) || isa(o.vlineAfter, 'dynDate'), ...
'@table.table: vlineAfter must be a dynDate');
if o.vlines
o.vline_after = '';
o.vlineAfter = '';
end
valid_title_sizes = {'Huge', 'huge', 'LARGE', 'Large', 'large', 'normalsize', ...
'small', 'footnotesize', 'scriptsize', 'tiny'};
assert(any(strcmp(o.title_size, valid_title_sizes)), ...
['@table.table: title_size must be one of ' strjoin(valid_title_sizes, ' ')]);
assert(any(strcmp(o.titleSize, valid_title_sizes)), ...
['@table.table: titleSize must be one of ' strjoin(valid_title_sizes, ' ')]);
% 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.seriestouse)
if isempty(o.seriesToUse)
for i=1:o.data.vobs
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.data.name{i}});
end
else
for i=1:length(o.seriestouse)
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriestouse{i}});
for i=1:length(o.seriesToUse)
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriesToUse{i}});
end
end
end
o = rmfield(o, 'seriestouse');
o = rmfield(o, 'seriesToUse');
o = rmfield(o, 'data');
% Create table object

View File

@ -58,8 +58,8 @@ for i=1:ndates
fprintf(fid, '|');
end
fprintf(fid, 'r');
if ~isempty(o.vline_after)
if dates(i) == o.vline_after
if ~isempty(o.vlineAfter)
if dates(i) == o.vlineAfter
fprintf(fid, '|');
end
end
@ -67,7 +67,7 @@ end
fprintf(fid, '@{}}%%\n');
if ~isempty(o.title)
fprintf(fid, '\\multicolumn{%d}{c}{\\%s %s}\\\\\n', ...
ndates+nlhc, o.title_size, o.title);
ndates+nlhc, o.titleSize, o.title);
end
fprintf(fid, '\\toprule%%\n');