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

View File

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

View File

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

View File

@ -43,7 +43,7 @@ fprintf(fid,'\n');
fprintf(fid, '\\begin{tabular}[t]{c}\n'); fprintf(fid, '\\begin{tabular}[t]{c}\n');
for i=1:length(o.title) 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 end
o.sections.write(fid); o.sections.write(fid);

View File

@ -36,7 +36,7 @@ o.title = '';
o.orientation = 'portrait'; o.orientation = 'portrait';
o.paper = 'a4'; o.paper = 'a4';
o.margin = 2.5; o.margin = 2.5;
o.margin_unit = 'cm'; o.marginUnit = 'cm';
o.pages = pages(); o.pages = pages();
o.filename = 'report.tex'; o.filename = 'report.tex';
o.config = ''; 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.'); assert(isfloat(o.margin) && o.margin > 0, '@report.report: margin must be a float > 0.');
valid_margin_unit = {'cm', 'in'}; valid_margin_unit = {'cm', 'in'};
assert(any(strcmp(o.margin_unit, valid_margin_unit)), ... assert(any(strcmp(o.marginUnit, valid_margin_unit)), ...
['@report.report: margin_unit must be one of ' strjoin(valid_margin_unit, ' ')]); ['@report.report: marginUnit must be one of ' strjoin(valid_margin_unit, ' ')]);
valid_paper = {'a4', 'letter'}; valid_paper = {'a4', 'letter'};
assert(any(strcmp(o.paper, valid_paper)), ... assert(any(strcmp(o.paper, valid_paper)), ...

View File

@ -36,7 +36,7 @@ end
fprintf(fid, '%% Report Object\n'); fprintf(fid, '%% Report Object\n');
fprintf(fid, '\\documentclass[11pt]{article}\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') if strcmpi(o.orientation, 'landscape')
fprintf(fid, ',landscape'); fprintf(fid, ',landscape');
end end

View File

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

View File

@ -36,19 +36,19 @@ o = struct;
o.data = ''; o.data = '';
o.color = 'k'; o.color = 'k';
o.line_style = '-'; o.lineStyle = '-';
o.line_width = 0.5; o.lineWidth = 0.5;
o.graph_marker = ''; o.graphMarker = '';
o.graph_marker_edge_color = 'auto'; o.graphMarkerEdgeColor = 'auto';
o.graph_marker_face_color = 'auto'; o.graphMarkerFaceColor = 'auto';
o.graph_marker_size = 6; o.graphMarkerSize = 6;
o.showTableMarkers = false; o.showTableMarkers = false;
o.table_neg_color = 'red'; o.tableNegColor = 'red';
o.table_pos_color = 'blue'; o.tablePosColor = 'blue';
o.table_align_right = false; o.tableAlignRight = false;
if nargin == 1 if nargin == 1
assert(isa(varargin{1}, 'series'),['@series.series: with one arg you ' ... 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'); '@series.write: must provide data as a dynSeries');
assert(ischar(o.color), '@series.write: color must be a string'); 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.tableNegColor), '@series.write: tableNegColor must be a string');
assert(ischar(o.table_pos_color), '@series.write: table_pos_color 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.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 %% Write Output
dataString = ['%.' num2str(precision) 'f']; dataString = ['%.' num2str(precision) 'f'];
precision = 10^precision; precision = 10^precision;
fprintf(fid, '%% Table Row (series)\n'); fprintf(fid, '%% Table Row (series)\n');
if o.table_align_right if o.tableAlignRight
fprintf(fid, '\\multicolumn{1}{r}{'); fprintf(fid, '\\multicolumn{1}{r}{');
end end
fprintf(fid, '%s', o.data.tex{:}); fprintf(fid, '%s', o.data.tex{:});
if o.table_align_right if o.tableAlignRight
fprintf(fid, '}'); fprintf(fid, '}');
end end
data = o.data(dates); data = o.data(dates);
@ -65,9 +65,9 @@ for i=1:size(data,1)
fprintf(fid, ' &'); fprintf(fid, ' &');
if o.showTableMarkers if o.showTableMarkers
if thisCellData < 0 if thisCellData < 0
fprintf(fid, '\\color{%s}', o.table_neg_color); fprintf(fid, '\\color{%s}', o.tableNegColor);
elseif thisCellData > 0 elseif thisCellData > 0
fprintf(fid, '\\color{%s}', o.table_pos_color); fprintf(fid, '\\color{%s}', o.tablePosColor);
end end
fprintf(fid, '['); fprintf(fid, '[');
end end

View File

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

View File

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