Mercurial > hg > octave-nkf
annotate scripts/plot/fill.m @ 10509:ddbd812d09aa
properly compress sparse matrices after assembly
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 12 Apr 2010 12:57:44 +0200 |
parents | eb63fbe60fab |
children | 95c3e38098bf |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2007, 2008, 2009 David Bateman |
7020 | 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 | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
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 | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} fill (@var{x}, @var{y}, @var{c}) | |
21 ## @deftypefnx {Function File} {} fill (@var{x1}, @var{y1}, @var{c1}, @var{x2}, @var{y2}, @var{c2}) | |
22 ## @deftypefnx {Function File} {} fill (@dots{}, @var{prop}, @var{val}) | |
23 ## @deftypefnx {Function File} {} fill (@var{h}, @dots{}) | |
7650 | 24 ## @deftypefnx {Function File} {@var{h} =} fill (@dots{}) |
7020 | 25 ## Create one or more filled patch objects, returning a patch object for each. |
26 ## @end deftypefn | |
27 | |
7216 | 28 function retval = fill (varargin) |
7020 | 29 |
7215 | 30 [h, varargin] = __plt_get_axis_arg__ ("fill", varargin{:}); |
7216 | 31 |
7020 | 32 htmp = []; |
7215 | 33 iargs = __find_patches__ (varargin{:}); |
7216 | 34 |
7215 | 35 oldh = gca (); |
36 unwind_protect | |
37 axes (h); | |
7020 | 38 |
39 for i = 1 : length (iargs) | |
40 if (i == length (iargs)) | |
41 args = varargin (iargs(i):end); | |
42 else | |
43 args = varargin (iargs(i):iargs(i+1)-1); | |
44 endif | |
7041 | 45 newplot (); |
7215 | 46 [tmp, fail] = __patch__ (h, args{:}); |
7020 | 47 if (fail) |
48 print_usage(); | |
49 endif | |
50 htmp (end + 1) = tmp; | |
51 endfor | |
7215 | 52 unwind_protect_cleanup |
53 axes (oldh); | |
54 end_unwind_protect | |
55 | |
7020 | 56 if (nargout > 0) |
7216 | 57 retval = htmp; |
7020 | 58 endif |
7215 | 59 |
7020 | 60 endfunction |
61 | |
62 function iargs = __find_patches__ (varargin) | |
63 iargs = []; | |
64 i = 1; | |
65 while (i < nargin) | |
66 iargs (end + 1) = i; | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
67 if (ischar (varargin{i}) |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
68 && (strcmpi (varargin{i}, "faces") |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
69 || strcmpi (varargin{i}, "vertices"))) |
7020 | 70 i += 4; |
7208 | 71 elseif (isnumeric (varargin{i})) |
7020 | 72 i += 2; |
73 endif | |
74 | |
75 if (i <= nargin) | |
76 while (true); | |
7208 | 77 if (ischar (varargin{i}) && |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
78 (strcmpi (varargin{i}, "faces") |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
79 || strcmpi (varargin{i}, "vertices"))) |
7020 | 80 break; |
7208 | 81 elseif (isnumeric (varargin{i})) |
7020 | 82 ## Assume its the colorspec |
83 i++; | |
84 break; | |
7208 | 85 elseif (ischar (varargin{i})) |
86 colspec = tolower (varargin{i}); | |
7020 | 87 collen = length (colspec); |
88 | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
89 if (strncmp (colspec, "blue", collen) |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
90 || strncmp (colspec, "black", collen) |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
91 || strncmp (colspec, "k", collen) |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
92 || strncmp (colspec, "black", collen) |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
93 || strncmp (colspec, "red", collen) |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
94 || strncmp (colspec, "green", collen) |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
95 || strncmp (colspec, "yellow", collen) |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
96 || strncmp (colspec, "magenta", collen) |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
97 || strncmp (colspec, "cyan", collen) |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
98 || strncmp (colspec, "white", collen)) |
7020 | 99 i++; |
100 break; | |
101 endif | |
102 else | |
103 i += 2; | |
104 endif | |
105 endwhile | |
106 endif | |
107 endwhile | |
108 endfunction | |
109 | |
110 %!demo | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
8243
diff
changeset
|
111 %! clf |
7020 | 112 %! t1 = (1/16:1/8:1)'*2*pi; |
113 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
114 %! x1 = sin(t1) - 0.8; | |
115 %! y1 = cos(t1); | |
116 %! x2 = sin(t2) + 0.8; | |
117 %! y2 = cos(t2); | |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
118 %! h = fill(x1,y1,'r',x2,y2,'g'); |