annotate scripts/plot/private/__errcomm__.m @ 17481:576cf0589c6d

Overhaul contour labeling functions. * scripts/plot/clabel.m: Use 'h', rather than 'retval', to match variables to documentation. Improve performance of input processing by using try/catch block and eliminating for loops. * scripts/plot/private/__clabel__.m: Get X and Y spacing in points from axis rather than assuming 4"x3" plot figure. Fix incorrect determination of axis limits if no contour handle provided. Rename loop vars i1, j1 to i,j. Performance improvement by using bsxfun over repmat. Use find to replace while loop (slow). Keep label rotation in the range [-90, 90] for readability.
author Rik <rik@octave.org>
date Tue, 24 Sep 2013 13:16:50 -0700
parents 4a6a4657fdf2
children
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: 11523
diff changeset
1 ## Copyright (C) 2001-2012 Teemu Ikonen
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
2 ##
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
4 ##
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## your option) any later version.
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
9 ##
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
14 ##
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
18
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
19 ## -*- texinfo -*-
17184
abf384f5d243 maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents: 14868
diff changeset
20 ## @deftypefn {Function File} {} __errcomm__ (@var{caller}, @var{hax}, @dots{})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6404
diff changeset
21 ## Undocumented internal function.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
22 ## @end deftypefn
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
23
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
24 ## Created: 20.02.2001
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
25 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi>
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
26 ## Keywords: errorbar, plotting
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
27
17184
abf384f5d243 maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents: 14868
diff changeset
28 function retval = __errcomm__ (caller, hax, varargin)
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
29
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
30 if (nargin < 4)
17184
abf384f5d243 maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents: 14868
diff changeset
31 print_usage (caller);
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
32 endif
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
33
10580
1479b93ee655 Respect linestyleorder in errorbar plots
David Bateman <dbateman@free.fr>
parents: 10549
diff changeset
34 retval = [];
17443
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
35 data = cell (6,1);
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
36 nargs = numel (varargin);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
37 k = 1;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
38 while (k <= nargs)
17443
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
39 arg = varargin{k++};
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
40 if (! ismatrix (arg))
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
41 error ("%s: data argument %d must be numeric", caller, k-1);
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
42 endif
17443
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
43 if (isvector (arg))
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
44 arg = arg(:);
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
45 endif
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
46 sz = size (arg);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
47 ndata = 1;
17443
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
48 data{ndata} = arg;
4897
89eee52fd4c7 [project @ 2004-06-03 23:07:55 by jwe]
jwe
parents: 4772
diff changeset
49 while (k <= nargs)
17443
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
50 arg = varargin{k++};
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
51 if (ischar (arg) || iscellstr (arg))
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
52 retval(end+1,1) = __errplot__(arg, hax, data{1:ndata});
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
53 break;
17443
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
54 endif
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
55 if (! ismatrix (arg))
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
56 error ("%s: data argument %d must be numeric", caller, k-1);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
57 endif
17443
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
58 if (isvector (arg))
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
59 arg = arg(:);
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
60 endif
17443
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
61 if (any (size (arg) != sz))
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
62 error ("%s: size of argument %d does not match others", caller, k-1);
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
63 endif
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
64 data{++ndata} = arg;
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
65 if (ndata > 6)
17184
abf384f5d243 maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents: 14868
diff changeset
66 error ("%s: too many arguments to plot", caller);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
67 endif
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
68 endwhile
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
69 endwhile
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
70
17443
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
71 ## No format code found, use yerrorbar
4a6a4657fdf2 Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents: 17346
diff changeset
72 if (! (ischar (arg) || iscellstr (arg)))
17184
abf384f5d243 maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents: 14868
diff changeset
73 retval = [retval; __errplot__("~", hax, data{1:ndata})];
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
74 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
75
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6146
diff changeset
76 drawnow ();
4019
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
77
c6d7ae9fcdb9 [project @ 2002-08-05 16:42:36 by jwe]
jwe
parents:
diff changeset
78 endfunction
17346
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 17184
diff changeset
79