Mercurial > octave-nkf
annotate scripts/plot/draw/private/__errcomm__.m @ 20438:5b7d7051a032 stable
Fix hang when using errorbar with empty dataset (bug #45554).
* __errcomm__.m: Use concatenation to append new errorbar plots to retval,
rather than assignment which can fail if the RHS is empty.
* __errplot__.m: Determine number of plots by checking number of columns in
dataset, but only if dataset is not empty (row is zero for example). Only
process a legend key if the number of plots is greater than 0.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 28 Jul 2015 08:47:27 -0700 |
parents | 00e31f316a3a |
children |
rev | line source |
---|---|
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
1 ## Copyright (C) 2001-2015 Teemu Ikonen |
4019 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
4019 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
4019 | 18 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
19 ## -*- texinfo -*- |
17176
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 | 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 | 23 |
24 ## Created: 20.02.2001 | |
25 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi> | |
26 ## Keywords: errorbar, plotting | |
27 | |
17176
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 | 29 |
6257 | 30 if (nargin < 4) |
17176
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 | 32 endif |
33 | |
10580
1479b93ee655
Respect linestyleorder in errorbar plots
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
34 retval = []; |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
35 data = cell (6,1); |
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
36 nargs = numel (varargin); |
6257 | 37 k = 1; |
38 while (k <= nargs) | |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
39 arg = varargin{k++}; |
19734
00e31f316a3a
Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19731
diff
changeset
|
40 if (! isnumeric (arg)) |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
41 error ("%s: data argument %d must be numeric", caller, k-1); |
4019 | 42 endif |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
43 if (isvector (arg)) |
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
44 arg = arg(:); |
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
45 endif |
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
46 sz = size (arg); |
6257 | 47 ndata = 1; |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
48 data{ndata} = arg; |
4897 | 49 while (k <= nargs) |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
50 arg = varargin{k++}; |
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
51 if (ischar (arg) || iscellstr (arg)) |
20438
5b7d7051a032
Fix hang when using errorbar with empty dataset (bug #45554).
Rik <rik@octave.org>
parents:
19734
diff
changeset
|
52 retval = [retval; __errplot__(arg, hax, data{1:ndata})]; |
10549 | 53 break; |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
54 endif |
19734
00e31f316a3a
Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19731
diff
changeset
|
55 if (! isnumeric (arg)) |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
56 error ("%s: data argument %d must be numeric", caller, k-1); |
6257 | 57 endif |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
58 if (isvector (arg)) |
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
59 arg = arg(:); |
4019 | 60 endif |
17594
f957fa0d2748
Allow scalar,vector inputs to match a matrix input for errorbar plots.
Rik <rik@octave.org>
parents:
17572
diff
changeset
|
61 if (! isscalar (arg) && ((isvector (arg) && numel (arg) != prod (sz)) |
f957fa0d2748
Allow scalar,vector inputs to match a matrix input for errorbar plots.
Rik <rik@octave.org>
parents:
17572
diff
changeset
|
62 || any (size (arg) != sz))) |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
63 error ("%s: size of argument %d does not match others", caller, k-1); |
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
64 endif |
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
65 data{++ndata} = arg; |
6257 | 66 if (ndata > 6) |
17176
abf384f5d243
maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
67 error ("%s: too many arguments to plot", caller); |
6257 | 68 endif |
4019 | 69 endwhile |
6257 | 70 endwhile |
4019 | 71 |
17435
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
72 ## No format code found, use yerrorbar |
4a6a4657fdf2
Overhaul errorbar family of functions.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
73 if (! (ischar (arg) || iscellstr (arg))) |
17176
abf384f5d243
maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
74 retval = [retval; __errplot__("~", hax, data{1:ndata})]; |
6257 | 75 endif |
76 | |
77 drawnow (); | |
4019 | 78 |
79 endfunction | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17176
diff
changeset
|
80 |