Hi,In Octave script dateaxis.m I found a little bug + a leftover debugging "keyboard" statement. It also invokes a stray gnuplot if called with too many arguments.
The bug is that argument "startdate" is actually ignored.
I've fixed these issues and attached an updated dateaxis.m to this message. Hopefully I correctly interpreted the intended use of optional 3rd argument "startdate" :-)
Would the maintainer(s) please update this script in the "financial" package? (I've cc'd the maintainer mentioned in DESCRIPTION)
BTW I'd say this script belongs in the time package (core octave) rather than in financial.
Philip
## Copyright (C) 2008 Bill Denney ## ## This software is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This software is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this software; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} {} dateaxis () ## @deftypefnx {Function File} {} dateaxis (ax) ## @deftypefnx {Function File} {} dateaxis (ax, dateform) ## @deftypefnx {Function File} {} dateaxis (ax, dateform, startdate) ## @deftypefnx {Function File} {} dateaxis (h, ...) ## ## Convert the current axis tick labels (or the axis handle @var{h}) to ## a date format. The axis given by @var{ax} ("x", "y", or "z") will be ## changed; the default is "x". The date format, @var{dateform}, used ## will be either auto-determined or an integer corresponding to the ## date formats in datestr. If @var{startdate} is given, then the first ## tick value on the given axis is assumed to be that date. ## ## @seealso{bolling, candle, highlow, movavg, pointfig} ## @end deftypefn ## Author: Bill Denney <[email protected]> ## Created: 2 Feb 2008 ## ## Slightly adapted by Philip Nienhuis, 20 sep 2009 ## (removed keyboard debug statement & added fix for startdate ## & added return below print_usage() to avoid stray gnuplot invocation function dateaxis (varargin) ## defaults h = gca (); ax = "x"; dateform = []; startdate = []; ## check inputs if nargin > 0 if ishandle(varargin{1}) h = varargin{1}; varargin(1) = []; endif if length(varargin) > 0 ax = varargin{1}; endif if length(varargin) > 1 dateform = varargin{2}; endif if length(varargin) > 2 startdate = varargin{3}; if ischar(startdate) startdate = datenum(startdate); elseif ~isnumeric(startdate) error ("startdate must be either a datenum or numeric") endif endif if length(varargin) > 3 print_usage (); ## Added by PRN oct 2009 return endif endif if isempty(dateform) r = range(get(h, [ax "lim"])); if r < 10/60/24 ## minutes and seconds dateform = 13; elseif r < 2 ## hours dateform = 15; elseif r < 15 ## days dateform = 8; elseif r < 365 ## months dateform = 6; elseif r < 90*12 ## quarters dateform = 27; else ## years dateform = 10; endif endif ticks = get (h, [ax "tick"]); ## Added by PRN oct 2009 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); endfunction
------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference
_______________________________________________ Octave-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/octave-dev
