Skip to content
Snippets Groups Projects
Verified Commit 44c36549 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Add option --with-legend.

parent 5622c45f
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,10 @@ function dplot(varargin)
ts = cell(1, length(data)*length(expressions)); l = 0;
Expressions = cell(size(expressions));
if iswithlegend(varargin)
legendnames = {};
end
for i=1:length(data)
for j=1:length(expressions)
% Check that brackets are balanced
......@@ -105,6 +109,9 @@ function dplot(varargin)
Expressions{j} = rewrite(expressions{j}, listofvariables, i);
l = l+1;
ts{l} = eval(Expressions{j});
if iswithlegend(varargin)
legendnames{l} = sprintf('%s [%s]', expressions{j}, names{i});
end
end
end
%
......@@ -127,6 +134,9 @@ function dplot(varargin)
id = ax.XTick;
dd = strings(range(id));
ax.XTickLabel = dd;
if iswithlegend(varargin)
legend(legendnames{:}, 'Location','SouthOutside','Orientation','horizontal','Box','off')
end
end
function expr = getexpressions(cellarray)
......@@ -163,6 +173,20 @@ function names = getdseriesnames(cellarray)
names = cellarray(dpos+1);
end
function bool = iswithlegend(cellarray)
% Return true if and only if a legend below the plot is required.
%
% INPUTS
% - cellarray [char] 1×n cell array of row char arrays.
%
% OUTPUTS
% - bool [dates] scalar.
bool = contains('--with-legend', cellarray);
end
function range = getrange(cellarray)
% Return period range for the plots.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment