Mercurial > octave
comparison scripts/plot/private/__pie__.m @ 11338:892ef3688ccf
__pie__.m: improve error messages
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 09 Dec 2010 19:24:00 -0500 |
parents | 4d0cfbe59fd2 |
children | 3c7ba1e3dc21 |
comparison
equal
deleted
inserted
replaced
11337:24cbdeac8384 | 11338:892ef3688ccf |
---|---|
27 h = varargin{1}; | 27 h = varargin{1}; |
28 x = abs (varargin{2}); | 28 x = abs (varargin{2}); |
29 iarg = 3; | 29 iarg = 3; |
30 | 30 |
31 if (! isvector (x)) | 31 if (! isvector (x)) |
32 error ("__pie__: expecting vector argument"); | 32 error ("%s: expecting vector argument", caller); |
33 endif | 33 endif |
34 | 34 |
35 len = length (x); | 35 len = length (x); |
36 | 36 |
37 have_explode = false; | 37 have_explode = false; |
41 arg = varargin{iarg++}; | 41 arg = varargin{iarg++}; |
42 if (iscell (arg)) | 42 if (iscell (arg)) |
43 labels = arg; | 43 labels = arg; |
44 have_labels = true; | 44 have_labels = true; |
45 if (numel (x) != numel (labels)) | 45 if (numel (x) != numel (labels)) |
46 error ("__pie__: mismatch in number of labels and data"); | 46 error ("%s: mismatch in number of labels and data", caller); |
47 endif | 47 endif |
48 elseif (! ischar (arg)) | 48 elseif (isnumeric (arg) || islogical (arg)) |
49 explode = arg; | 49 explode = arg; |
50 have_explode = true; | 50 have_explode = true; |
51 if (! size_equal (x, explode)) | 51 if (! size_equal (x, explode)) |
52 error ("__pie__: mismatch in number of elements in explode and data"); | 52 error ("%s: mismatch in number of elements in explode and data", |
53 caller); | |
53 endif | 54 endif |
55 else | |
56 error ("%s: %s is invalid as an optional argument", caller, class (arg)); | |
54 endif | 57 endif |
55 endwhile | 58 endwhile |
56 | 59 |
57 if (! have_explode) | 60 if (! have_explode) |
58 explode = zeros (size (x)); | 61 explode = zeros (size (x)); |
120 | 123 |
121 hlist = [hlist; patch(xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], i); | 124 hlist = [hlist; patch(xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], i); |
122 text(xt, yt, labels{i}, "horizontalalignment", align)]; | 125 text(xt, yt, labels{i}, "horizontalalignment", align)]; |
123 | 126 |
124 else | 127 else |
125 error ("__pie__: unknown caller"); | 128 error ("__pie__: unknown caller `%s'", caller); |
126 endif | 129 endif |
127 endfor | 130 endfor |
128 | 131 |
129 addlistener(gca, "view", {@update_text_pos, hlist}); | 132 addlistener(gca, "view", {@update_text_pos, hlist}); |
130 | 133 |