reporting: support horizontal lines
parent
d470ef16ca
commit
0247faa9ed
|
@ -11356,7 +11356,7 @@ Whether or not to show vertical lines separating the columns. Default: @code{fal
|
|||
@end defmethod
|
||||
|
||||
@anchor{addSeries}
|
||||
@defmethod Report addSeries data, graphLegendName, graphLineColor, graphLineStyle, graphLineWidth, graphMarker, graphMarkerEdgeColor, graphMarkerFaceColor, graphMarkerSize, graphMiscTikzAddPlotOptions, graphVline, tableDataRhs, tableRowColor, tableRowIndent, tableShowMarkers, tableAlignRight, tableNegColor, tablePosColor, tableSubSectionHeader, zeroTol
|
||||
@defmethod Report addSeries data, graphHline, graphLegendName, graphLineColor, graphLineStyle, graphLineWidth, graphMarker, graphMarkerEdgeColor, graphMarkerFaceColor, graphMarkerSize, graphMiscTikzAddPlotOptions, graphVline, tableDataRhs, tableRowColor, tableRowIndent, tableShowMarkers, tableAlignRight, tableNegColor, tablePosColor, tableSubSectionHeader, zeroTol
|
||||
Adds a @code{Series} to a @code{Graph} or a @code{Table}.
|
||||
@optionshead
|
||||
@table @code
|
||||
|
@ -11364,6 +11364,10 @@ Adds a @code{Series} to a @code{Graph} or a @code{Table}.
|
|||
@item data, @code{dseries}
|
||||
@xref{data}.
|
||||
|
||||
@item graphHline, @code{DOUBLE}
|
||||
Use this option to draw a horizontal line at the given value. Default:
|
||||
@code{empty}
|
||||
|
||||
@anchor{graphLegendName}
|
||||
@item graphLegendName, @code{STRING}
|
||||
The name to display in the legend for this series. Will be displayed only if
|
||||
|
|
|
@ -48,6 +48,7 @@ o.graphMarkerSize = 1;
|
|||
|
||||
o.graphMiscTikzAddPlotOptions = '';
|
||||
|
||||
o.graphHline = {};
|
||||
o.graphVline = dates();
|
||||
|
||||
o.tableShowMarkers = false;
|
||||
|
|
|
@ -30,7 +30,7 @@ function o = writeSeriesForGraph(o, fid, xrange)
|
|||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
%% Validate options provided by user
|
||||
if isempty(o.graphVline)
|
||||
if isempty(o.graphVline) && isempty(o.graphHline)
|
||||
assert(~isempty(o.data) && isa(o.data, 'dseries'), ['@report_series.writeSeriesForGraph: must ' ...
|
||||
'provide data as a dseries']);
|
||||
end
|
||||
|
@ -68,13 +68,15 @@ assert(~(strcmp(o.graphLineStyle, 'none') && isempty(o.graphMarker)), ['@report_
|
|||
|
||||
% Validate graphVline
|
||||
assert(isdates(o.graphVline), '@report_series.writeSeriesForGraph: graphVline must be a dates');
|
||||
assert(isempty(o.graphHline) || isnumeric(o.graphHline), ...
|
||||
'@report_series.writeSeriesForGraph: graphHline must a single numeric value');
|
||||
|
||||
% Zero tolerance
|
||||
assert(isfloat(o.zeroTol), '@report_series.write: zeroTol must be a float');
|
||||
|
||||
%% graphVline
|
||||
|
||||
if ~isempty(o.graphVline)
|
||||
if ~isempty(o.graphVline) || ~isempty(o.graphHline)
|
||||
for i=1:o.graphVline.ndat
|
||||
fprintf(fid, '%%vline %d\n\\begin{pgfonlayer}{background1}\n\\draw[color=%s,%s,line width=%fpt,line join=round',...
|
||||
i, o.graphLineColor, o.graphLineStyle, o.graphLineWidth);
|
||||
|
@ -97,6 +99,27 @@ if ~isempty(o.graphVline)
|
|||
'cs:%d,\\pgfkeysvalueof{/pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
|
||||
x, x);
|
||||
end
|
||||
|
||||
if ~isempty(o.graphHline)
|
||||
fprintf(fid, '%%hline %d\n\\begin{pgfonlayer}{background1}\n\\draw[color=%s,%s,line width=%fpt,line join=round',...
|
||||
i, o.graphLineColor, o.graphLineStyle, o.graphLineWidth);
|
||||
if ~isempty(o.graphMarker)
|
||||
if isempty(o.graphMarkerEdgeColor)
|
||||
o.graphMarkerEdgeColor = o.graphLineColor;
|
||||
end
|
||||
if isempty(o.graphMarkerFaceColor)
|
||||
o.graphMarkerFaceColor = o.graphLineColor;
|
||||
end
|
||||
fprintf(fid, ',mark=%s,mark size=%f,every mark/.append style={draw=%s,fill=%s}',...
|
||||
o.graphMarker,o.graphMarkerSize,o.graphMarkerEdgeColor,o.graphMarkerFaceColor);
|
||||
end
|
||||
if ~isempty(o.graphMiscTikzAddPlotOptions)
|
||||
fprintf(fid, ',%s', o.graphMiscTikzAddPlotOptions);
|
||||
end
|
||||
fprintf(fid, ['] (axis cs:\\pgfkeysvalueof{/pgfplots/xmin},%f) -- (axis ' ...
|
||||
'cs:\\pgfkeysvalueof{/pgfplots/xmax},%f);\n\\end{pgfonlayer}\n'], ...
|
||||
o.graphHline, o.graphHline);
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -234,6 +234,10 @@ rep = rep.addSeries('data', dc_q{'LRPFOOD_WORLD'}, ...
|
|||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep = rep.addSeries('graphHline', 460, ...
|
||||
'graphLineColor', 'red', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
|
||||
rep = rep.addGraph('title', 'Equilibrium World Real Food Price', ...
|
||||
'xrange', prange, ...
|
||||
|
|
Loading…
Reference in New Issue