annotate scripts/time/datetick.m @ 14363:f3d52523cde1

Use Octave coding conventions in all m-file %!test blocks * wavread.m, acosd.m, acot.m, acotd.m, acoth.m, acsc.m, acscd.m, acsch.m, asec.m, asecd.m, asech.m, asind.m, atand.m, cosd.m, cot.m, cotd.m, coth.m, csc.m, cscd.m, csch.m, sec.m, secd.m, sech.m, sind.m, tand.m, accumarray.m, accumdim.m, bitcmp.m, bitget.m, bitset.m, blkdiag.m, cart2pol.m, cart2sph.m, celldisp.m, chop.m, circshift.m, colon.m, common_size.m, cplxpair.m, cumtrapz.m, curl.m, dblquad.m, deal.m, divergence.m, flipdim.m, fliplr.m, flipud.m, genvarname.m, gradient.m, idivide.m, int2str.m, interp1.m, interp1q.m, interp2.m, interp3.m, interpft.m, interpn.m, isa.m, isdir.m, isequal.m, isequalwithequalnans.m, issquare.m, logspace.m, nargchk.m, narginchk.m, nargoutchk.m, nextpow2.m, nthargout.m, num2str.m, pol2cart.m, polyarea.m, postpad.m, prepad.m, profile.m, profshow.m, quadgk.m, quadv.m, randi.m, rat.m, repmat.m, rot90.m, rotdim.m, shift.m, shiftdim.m, sph2cart.m, structfun.m, trapz.m, triplequad.m, convhull.m, dsearch.m, dsearchn.m, griddata3.m, griddatan.m, rectint.m, tsearchn.m, __makeinfo__.m, doc.m, get_first_help_sentence.m, help.m, type.m, unimplemented.m, which.m, imread.m, imwrite.m, dlmwrite.m, fileread.m, is_valid_file_id.m, strread.m, textread.m, textscan.m, commutation_matrix.m, cond.m, condest.m, cross.m, duplication_matrix.m, expm.m, housh.m, isdefinite.m, ishermitian.m, issymmetric.m, logm.m, normest.m, null.m, onenormest.m, orth.m, planerot.m, qzhess.m, rank.m, rref.m, trace.m, vech.m, ans.m, bincoeff.m, bug_report.m, bzip2.m, comma.m, compare_versions.m, computer.m, edit.m, fileparts.m, fullfile.m, getfield.m, gzip.m, info.m, inputname.m, isappdata.m, isdeployed.m, ismac.m, ispc.m, isunix.m, list_primes.m, ls.m, mexext.m, namelengthmax.m, news.m, orderfields.m, paren.m, recycle.m, rmappdata.m, semicolon.m, setappdata.m, setfield.m, substruct.m, symvar.m, ver.m, version.m, warning_ids.m, xor.m, fminbnd.m, fsolve.m, fzero.m, lsqnonneg.m, optimset.m, pqpnonneg.m, sqp.m, matlabroot.m, __gnuplot_drawnow__.m, __plt_get_axis_arg__.m, ancestor.m, cla.m, clf.m, close.m, colorbar.m, colstyle.m, comet3.m, contourc.m, figure.m, gca.m, gcbf.m, gcbo.m, gcf.m, ginput.m, graphics_toolkit.m, gtext.m, hggroup.m, hist.m, hold.m, isfigure.m, ishghandle.m, ishold.m, isocolors.m, isonormals.m, isosurface.m, isprop.m, legend.m, line.m, loglog.m, loglogerr.m, meshgrid.m, ndgrid.m, newplot.m, orient.m, patch.m, plot3.m, plotyy.m, __print_parse_opts__.m, quiver3.m, refreshdata.m, ribbon.m, semilogx.m, semilogxerr.m, semilogy.m, stem.m, stem3.m, subplot.m, title.m, uigetfile.m, view.m, whitebg.m, compan.m, conv.m, deconv.m, mkpp.m, mpoles.m, pchip.m, poly.m, polyaffine.m, polyder.m, polyfit.m, polygcd.m, polyint.m, polyout.m, polyval.m, polyvalm.m, ppder.m, ppint.m, ppjumps.m, ppval.m, residue.m, roots.m, spline.m, intersect.m, ismember.m, powerset.m, setdiff.m, setxor.m, union.m, unique.m, autoreg_matrix.m, bartlett.m, blackman.m, detrend.m, fftconv.m, fftfilt.m, fftshift.m, freqz.m, hamming.m, hanning.m, ifftshift.m, sinc.m, sinetone.m, sinewave.m, unwrap.m, bicg.m, bicgstab.m, gmres.m, gplot.m, nonzeros.m, pcg.m, pcr.m, spaugment.m, spconvert.m, spdiags.m, speye.m, spfun.m, spones.m, sprand.m, sprandsym.m, spstats.m, spy.m, svds.m, treelayout.m, bessel.m, beta.m, betaln.m, factor.m, factorial.m, isprime.m, lcm.m, legendre.m, nchoosek.m, nthroot.m, perms.m, pow2.m, primes.m, reallog.m, realpow.m, realsqrt.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m, rosser.m, vander.m, __finish__.m, center.m, cloglog.m, corr.m, cov.m, gls.m, histc.m, iqr.m, kendall.m, kurtosis.m, logit.m, mahalanobis.m, mean.m, meansq.m, median.m, mode.m, moment.m, ols.m, ppplot.m, prctile.m, probit.m, quantile.m, range.m, ranks.m, run_count.m, runlength.m, skewness.m, spearman.m, statistics.m, std.m, table.m, var.m, zscore.m, betacdf.m, betainv.m, betapdf.m, betarnd.m, binocdf.m, binoinv.m, binopdf.m, binornd.m, cauchy_cdf.m, cauchy_inv.m, cauchy_pdf.m, cauchy_rnd.m, chi2cdf.m, chi2inv.m, chi2pdf.m, chi2rnd.m, discrete_cdf.m, discrete_inv.m, discrete_pdf.m, discrete_rnd.m, empirical_cdf.m, empirical_inv.m, empirical_pdf.m, empirical_rnd.m, expcdf.m, expinv.m, exppdf.m, exprnd.m, fcdf.m, finv.m, fpdf.m, frnd.m, gamcdf.m, gaminv.m, gampdf.m, gamrnd.m, geocdf.m, geoinv.m, geopdf.m, geornd.m, hygecdf.m, hygeinv.m, hygepdf.m, hygernd.m, kolmogorov_smirnov_cdf.m, laplace_cdf.m, laplace_inv.m, laplace_pdf.m, laplace_rnd.m, logistic_cdf.m, logistic_inv.m, logistic_pdf.m, logistic_rnd.m, logncdf.m, logninv.m, lognpdf.m, lognrnd.m, nbincdf.m, nbininv.m, nbinpdf.m, nbinrnd.m, normcdf.m, norminv.m, normpdf.m, normrnd.m, poisscdf.m, poissinv.m, poisspdf.m, poissrnd.m, stdnormal_cdf.m, stdnormal_inv.m, stdnormal_pdf.m, stdnormal_rnd.m, tcdf.m, tinv.m, tpdf.m, trnd.m, unidcdf.m, unidinv.m, unidpdf.m, unidrnd.m, unifcdf.m, unifinv.m, unifpdf.m, unifrnd.m, wblcdf.m, wblinv.m, wblpdf.m, wblrnd.m, kolmogorov_smirnov_test.m, kruskal_wallis_test.m, base2dec.m, bin2dec.m, blanks.m, cstrcat.m, deblank.m, dec2base.m, dec2bin.m, dec2hex.m, findstr.m, hex2dec.m, index.m, isletter.m, mat2str.m, rindex.m, str2num.m, strcat.m, strjust.m, strmatch.m, strsplit.m, strtok.m, strtrim.m, strtrunc.m, substr.m, validatestring.m, demo.m, example.m, fail.m, speed.m, addtodate.m, asctime.m, clock.m, ctime.m, date.m, datenum.m, datetick.m, datevec.m, eomday.m, etime.m, is_leap_year.m, now.m: Use Octave coding conventions in all m-file %!test blocks
author Rik <octave@nomad.inbox5.com>
date Mon, 13 Feb 2012 07:29:44 -0800
parents 11949c9795a0
children 86854d032a37
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13082
diff changeset
1 ## Copyright (C) 2008-2012 David Bateman
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
2 ##
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
3 ## This file is part of Octave.
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
4 ##
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
8 ## your option) any later version.
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 ##
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
13 ## General Public License for more details.
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
14 ##
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
18
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10369
diff changeset
20 ## @deftypefn {Function File} {} datetick ()
10151
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
21 ## @deftypefnx {Function File} {} datetick (@var{form})
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
22 ## @deftypefnx {Function File} {} datetick (@var{axis}, @var{form})
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
23 ## @deftypefnx {Function File} {} datetick (@dots{}, "keeplimits")
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
24 ## @deftypefnx {Function File} {} datetick (@dots{}, "keepticks")
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
25 ## @deftypefnx {Function File} {} datetick (@dots{ax}, @dots{})
12575
d0b799dafede Grammarcheck files for 3.4.1 release.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
26 ## Add date formatted tick labels to an axis. The axis the apply the
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
27 ## ticks to is determined by @var{axis} that can take the values "x",
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8325
diff changeset
28 ## "y" or "z". The default value is "x". The formatting of the labels is
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
29 ## determined by the variable @var{form}, that can either be a string in
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
30 ## the format needed by @code{dateform}, or a positive integer that can
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
31 ## be accepted by @code{datestr}.
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
32 ## @seealso{datenum, datestr}
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
33 ## @end deftypefn
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
34
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
35 function datetick (varargin)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
36
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
37 [h, varargin, nargin] = __plt_get_axis_arg__ ("datetick", varargin{:});
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
38
10151
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
39 oldh = gca ();
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
40 unwind_protect
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
41 axes (h);
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
42 __datetick__ (varargin{:});
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
43 unwind_protect_cleanup
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
44 axes (oldh);
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
45 end_unwind_protect
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
46
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
47 endfunction
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
48
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
49
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
50 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
51 %! clf;
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
52 %! yr = 1900:10:2000;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
53 %! pop = [76.094, 92.407, 106.461, 123.077 131.954, 151.868, 179.979, ...
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
54 %! 203.984, 227.225, 249.623, 282.224];
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
55 %! plot (datenum (yr, 1, 1), pop);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
56 %! title ("US population (millions)");
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 %! xlabel ("Year");
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
58 %! datetick ("x", "YYYY");
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
59
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
60 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
61 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
62 %! yr = 1988:2:2002;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
63 %! yr = datenum (yr,1,1);
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
64 %! pr = [12.1 13.3 12.6 13.1 13.3 14.1 14.4 15.2];
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
65 %! plot (yr, pr);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
66 %! xlabel ("year");
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
67 %! ylabel ("average price");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
68 %! ax = gca;
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
69 %! set (ax, "xtick", datenum (1990:5:2005,1,1));
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
70 %! datetick (2, "keepticks");
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
71 %! set (ax, "ytick", 12:16);
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
72
13082
35c0b722d2e4 codesprint: mark datetick as tested.
John W. Eaton <jwe@octave.org>
parents: 12575
diff changeset
73 ## Remove from test statistics. No real tests possible.
35c0b722d2e4 codesprint: mark datetick as tested.
John W. Eaton <jwe@octave.org>
parents: 12575
diff changeset
74 %!assert (1)
35c0b722d2e4 codesprint: mark datetick as tested.
John W. Eaton <jwe@octave.org>
parents: 12575
diff changeset
75
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
76 function __datetick__ (varargin)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
77
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
78 keeplimits = false;
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
79 keepticks = false;
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
80 idx = [];
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
81 for i = 1 : nargin
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
82 arg = varargin {i};
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
83 if (ischar (arg))
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
84 if (strcmpi (arg, "keeplimits"))
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
85 keeplimits = true;
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
86 idx = [idx, i];
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
87 elseif (strcmpi (arg, "keepticks"))
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
88 keepticks = true;
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
89 idx = [idx, i];
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
90 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
91 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
92 endfor
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
93
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
94 varargin(idx) = [];
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
95 nargin = length (varargin);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
96 form = [];
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
97 ax = "x";
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
98
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
99 if (nargin != 0)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
100 arg = varargin{1};
11149
fe3c3dfc07eb style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents: 10793
diff changeset
101 if (ischar (arg) && (strcmp (arg, "x") || strcmp (arg, "y")
fe3c3dfc07eb style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents: 10793
diff changeset
102 || strcmp (arg, "z")))
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
103 ax = arg;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
104 if (nargin > 1)
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
105 form = varargin{2};
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
106 varargin(1:2) = [];
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
107 else
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
108 varargin(1) = [];
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
109 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
110 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
111 form = arg;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
112 varargin(1) = [];
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
113 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
114 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
115
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
116 ## Don't publish the existence of this variable for use with dateaxis
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
117 if (length (varargin) > 0)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
118 startdate = varargin{1};
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
119 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
120 startdate = [];
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
121 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
122
10151
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
123 if (! isempty (form))
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
124 if (isnumeric (form))
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
125 if (! isscalar (form) || floor (form) != form || form < 0)
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 11294
diff changeset
126 error ("datetick: expecting FORM argument to be a positive integer");
10151
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
127 endif
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
128 elseif (! ischar (form))
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
129 error ("datetick: expecting valid date format string");
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
130 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
131 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
132
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
133 if (keepticks)
11294
e2a4f3478b7c datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents: 11149
diff changeset
134 ticks = get (gca (), strcat (ax, "tick"));
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
135 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
136 ## Need to do our own axis tick position calculation as
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
137 ## year, etc, don't fallback on nice datenum values.
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
138 objs = findall (gca());
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
139 xmax = NaN;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
140 xmin = NaN;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
141 for i = 1 : length (objs)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
142 fld = get (objs (i));
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
143 if (isfield (fld, strcat (ax, "data")))
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
144 xdata = getfield (fld, strcat (ax, "data"))(:);
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
145 xmin = min (xmin, min (xdata));
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
146 xmax = max (xmax, max (xdata));
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
147 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
148 endfor
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
149
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
150 if (isnan (xmin) || isnan (xmax))
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
151 xmin = 0;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
152 xmax = 1;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
153 elseif (xmin == xmax)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
154 xmax = xmin + 1;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
155 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
156
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
157 N = 3;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
158 if (xmax - xmin < N)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
159 ## Day scale or less
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
160 if (xmax - xmin < N / 24 / 60 / 60)
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
161 scl = 1 / 24 / 60 / 60;
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
162 elseif (xmax - xmin < N / 24 / 6)
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
163 scl = 1 / 24 / 60;
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
164 else
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
165 scl = 1 / 24;
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
166 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
167 sep = __calc_tick_sep__ (xmin / scl , xmax / scl);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
168 xmin = sep * floor (xmin / scl / sep);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
169 xmax = sep * ceil (xmax / scl / sep);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
170 nticks = (xmax - xmin) / sep + 1;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
171 xmin *= scl;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
172 xmax *= scl;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
173 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
174 [ymin, mmin, dmin] = datevec (xmin);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
175 [ymax, mmax, dmax] = datevec (xmax);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
176 minyear = ymin + (mmin - 1) / 12 + (dmin - 1) / 12 / 30;
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
177 maxyear = ymax + (mmax - 1) / 12 + (dmax - 1) / 12 / 30;
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
178 minmonth = mmin + (dmin - 1) / 30;
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
179 maxmonth = (ymax - ymin) * 12 + mmax + (dmax - 1) / 30;
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
180
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
181 if (maxmonth - minmonth < N)
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
182 sep = __calc_tick_sep__ (xmin, xmax);
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
183 xmin = sep * floor (xmin / sep);
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
184 xmax = sep * ceil (xmax / sep);
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
185 nticks = (xmax - xmin) / sep + 1;
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
186 elseif (maxyear - minyear < N)
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
187 sep = __calc_tick_sep__ (minmonth , maxmonth);
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
188 xmin = datenum (ymin, sep * floor (minmonth / sep), 1);
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
189 xmax = datenum (ymin, sep * ceil (maxmonth / sep), 1);
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
190 nticks = ceil (maxmonth / sep) - floor (minmonth / sep) + 1;
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
191 else
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
192 sep = __calc_tick_sep__ (minyear , maxyear);
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
193 xmin = datenum (sep * floor (minyear / sep), 1, 1);
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
194 xmax = datenum (sep * ceil (maxyear / sep), 1, 1);
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
195 nticks = ceil (maxyear / sep) - floor (minyear / sep) + 1;
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
196 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
197 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
198 ticks = xmin + [0 : nticks - 1] / (nticks - 1) * (xmax - xmin);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
199 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
200
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
201 if (isempty (form))
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
202 r = max(ticks) - min(ticks);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
203 if r < 10/60/24
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
204 ## minutes and seconds
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
205 form = 13;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
206 elseif r < 2
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
207 ## hours
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
208 form = 15;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
209 elseif r < 15
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
210 ## days
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
211 form = 8;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
212 elseif r < 365
10151
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
213 ## FIXME -- FORM should be 19 for European users who use dd/mm
c2f1cdb59821 datetick: make form argument optional
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
214 ## instead of mm/dd. How can that be determined automatically?
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
215 ## months
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
216 form = 6;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
217 elseif r < 90*12
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
218 ## quarters
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
219 form = 27;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
220 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
221 ## years
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
222 form = 10;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
223 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
224 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
225
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
226 if (length (ticks) == 6)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
227 ## Careful that its not treated as a datevec
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
228 if (! isempty (startdate))
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
229 sticks = strvcat (datestr (ticks(1:end-1) - ticks(1) + startdate, form),
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
230 datestr (ticks(end) - ticks(1) + startdate, form));
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
231 else
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
232 sticks = strvcat (datestr (ticks(1:end-1), form),
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
233 datestr (ticks(end), form));
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
234 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
235 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
236 if (! isempty (startdate))
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
237 sticks = datestr (ticks - ticks(1) + startdate, form);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
238 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
239 sticks = datestr (ticks, form);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
240 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
241 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
242
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
243 sticks = mat2cell (sticks, ones (rows (sticks), 1), columns (sticks));
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
244
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
245 if (keepticks)
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
246 if (keeplimits)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
247 set (gca(), strcat (ax, "ticklabel"), sticks);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
248 else
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
249 set (gca(), strcat (ax, "ticklabel"), sticks, strcat (ax, "lim"),
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
250 [min(ticks), max(ticks)]);
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
251 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
252 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
253 if (keeplimits)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
254 set (gca(), strcat (ax, "tick"), ticks, strcat (ax, "ticklabel"), sticks);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
255 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
256 set (gca(), strcat (ax, "tick"), ticks, strcat (ax, "ticklabel"), sticks,
10369
3516a245d607 datetick.m: Fix 'keepticks' bug, and untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10151
diff changeset
257 strcat (ax, "lim"), [min(ticks), max(ticks)]);
8112
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
258 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
259 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
260 endfunction
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
261
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
262 function [a, b] = __magform__ (x)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
263 if (x == 0)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
264 a = 0;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
265 b = 0;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
266 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
267 l = log10 (abs (x));
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
268 r = fmod (l, 1);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
269 a = 10 .^ r;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
270 b = fix (l - r);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
271 if (a < 1)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
272 a *= 10;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
273 b -= 1;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
274 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
275 if (x < 0)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
276 a = -a;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
277 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
278 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
279 endfunction
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
280
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
281 ## A translation from Tom Holoryd's python code at
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
282 ## http://kurage.nimh.nih.gov/tomh/tics.py
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
283 function sep = __calc_tick_sep__ (lo, hi)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
284 persistent sqrt_2 = sqrt (2.0);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
285 persistent sqrt_10 = sqrt (10.0);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
286 persistent sqrt_50 = sqrt (50.0);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
287
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
288 ticint = 5;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
289
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
290 ## Reference: Lewart, C. R., "Algorithms SCALE1, SCALE2, and
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
291 ## SCALE3 for Determination of Scales on Computer Generated
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
292 ## Plots", Communications of the ACM, 10 (1973), 639-640.
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
293 ## Also cited as ACM Algorithm 463.
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
294
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
295 [a, b] = __magform__ ((hi - lo) / ticint);
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
296
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
297 if (a < sqrt_2)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
298 x = 1;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
299 elseif (a < sqrt_10)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
300 x = 2;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
301 elseif (a < sqrt_50)
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
302 x = 5;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
303 else
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
304 x = 10;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
305 endif
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
306 sep = x * 10 .^ b;
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
307 endfunction
31e86163b752 Add the datetick function
David Bateman <dbateman@free.fr>
parents:
diff changeset
308