Mercurial > forge
changeset 6628:cd1c792e309f octave-forge
Move 'gca' call to avoid windows popping up if an error occures. Also, ensure we don't add an empty matrix to the ticks
author | hauberg |
---|---|
date | Sun, 31 Jan 2010 17:18:58 +0000 |
parents | 72079d5a40bc |
children | 95ac31b422e4 |
files | main/financial/inst/dateaxis.m |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/main/financial/inst/dateaxis.m Sun Jan 31 12:36:06 2010 +0000 +++ b/main/financial/inst/dateaxis.m Sun Jan 31 17:18:58 2010 +0000 @@ -37,7 +37,7 @@ function dateaxis (varargin) ## defaults - h = gca (); + h = []; ax = "x"; dateform = []; startdate = []; @@ -59,13 +59,17 @@ if ischar(startdate) startdate = datenum(startdate); elseif ~isnumeric(startdate) - error ("startdate must be either a datenum or numeric") + error ("dateaxis: startdate must be either a datenum or numeric") endif endif if length(varargin) > 3 print_usage (); endif endif + + if (isempty (h)) + h = gca (); + endif if isempty(dateform) r = range(get(h, [ax "lim"])); @@ -91,7 +95,9 @@ endif ticks = get (h, [ax "tick"]); - ticks = ticks - ticks(1) + startdate; + if (!isempty (startdate)) + ticks = ticks - ticks(1) + startdate; + endif ticks = datestr(ticks, dateform); ticks = mat2cell(ticks, ones(size(ticks,1),1), size(ticks,2)); set (h, [ax "ticklabel"], ticks);