annotate scripts/plot/__pltopt1__.m @ 6459:5dc550e1f419

[project @ 2007-03-26 18:11:58 by jwe]
author jwe
date Mon, 26 Mar 2007 18:11:58 +0000
parents af8e28709a2c
children 781777998927
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 1996, 1997 John W. Eaton
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
2 ##
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
4 ##
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 2, or (at your option)
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
8 ## any later version.
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
9 ##
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
14 ##
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5053
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5053
diff changeset
18 ## 02110-1301, USA.
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
19
3407
5e0a0b1cba43 [project @ 2000-01-06 03:13:55 by jwe]
jwe
parents: 3233
diff changeset
20 ## -*- texinfo -*-
3500
7923abdeb4e5 [project @ 2000-01-31 06:35:00 by jwe]
jwe
parents: 3449
diff changeset
21 ## @deftypefn {Function File} {} __pltopt1__ (@var{caller}, @var{opt})
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
22 ## Really decode plot option strings.
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5462
diff changeset
23 ## @seealso{__pltopt__}
3407
5e0a0b1cba43 [project @ 2000-01-06 03:13:55 by jwe]
jwe
parents: 3233
diff changeset
24 ## @end deftypefn
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
25
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
26 ## Author: Rick Niles <niles@axp745.gsfc.nasa.gov>
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
27 ## Adapted-By: jwe
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
28 ## Maintainer: jwe
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
29
6459
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
30 function [options, valid] = __pltopt1__ (caller, opt, err_on_invalid)
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
31
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
32 options = __default_plot_options__ ();
6459
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
33 valid = true;
4841
66fb9f8c66c8 [project @ 2004-03-12 23:02:54 by jwe]
jwe
parents: 4260
diff changeset
34
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
35 more_opts = 1;
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
36
6459
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
37 if (nargin != 2 && nargin != 3)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
38 print_usage ();
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
39 endif
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
40
5443
ec8c33dcd1bf [project @ 2005-09-08 01:40:57 by jwe]
jwe
parents: 5405
diff changeset
41 if (! ischar (opt))
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents: 6085
diff changeset
42 return;
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
43 endif
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
44
6395
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6264
diff changeset
45 have_linestyle = false;
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6264
diff changeset
46 have_marker = false;
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6264
diff changeset
47
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
48 while (! isempty (opt))
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
49 if (strncmp (opt, "--", 2) || strncmp (opt, "-.", 2))
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
50 options.linestyle = opt(1:2);
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
51 n = 2;
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
52 else
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
53 topt = opt(1);
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
54 n = 1;
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
55 if (topt == "-" || topt == ":")
6395
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6264
diff changeset
56 have_linestyle = true;
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
57 options.linestyle = topt;
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
58 elseif (topt == "+" || topt == "o" || topt == "*"
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
59 || topt == "." || topt == "x" || topt == "s"
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
60 || topt == "d" || topt == "^" || topt == "v"
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
61 || topt == ">" || topt == "<" || topt == "p"
6442
1896d9b1f302 [project @ 2007-03-23 16:10:33 by jwe]
jwe
parents: 6395
diff changeset
62 || topt == "h" || topt == "@")
6395
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6264
diff changeset
63 have_marker = true;
6442
1896d9b1f302 [project @ 2007-03-23 16:10:33 by jwe]
jwe
parents: 6395
diff changeset
64 ## Backward compatibility. Leave undocumented.
1896d9b1f302 [project @ 2007-03-23 16:10:33 by jwe]
jwe
parents: 6395
diff changeset
65 if (topt == "@")
1896d9b1f302 [project @ 2007-03-23 16:10:33 by jwe]
jwe
parents: 6395
diff changeset
66 topt = "+";
1896d9b1f302 [project @ 2007-03-23 16:10:33 by jwe]
jwe
parents: 6395
diff changeset
67 endif
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
68 options.marker = topt;
6444
af8e28709a2c [project @ 2007-03-23 16:42:50 by jwe]
jwe
parents: 6442
diff changeset
69 ### Numeric color specs for backward compatibility. Leave undocumented.
af8e28709a2c [project @ 2007-03-23 16:42:50 by jwe]
jwe
parents: 6442
diff changeset
70 elseif (topt == "k" || topt == "0")
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
71 options.color = [0, 0, 0];
6444
af8e28709a2c [project @ 2007-03-23 16:42:50 by jwe]
jwe
parents: 6442
diff changeset
72 elseif (topt == "r" || topt == "1")
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
73 options.color = [1, 0, 0];
6444
af8e28709a2c [project @ 2007-03-23 16:42:50 by jwe]
jwe
parents: 6442
diff changeset
74 elseif (topt == "g" || topt == "2")
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
75 options.color = [0, 1, 0];
6444
af8e28709a2c [project @ 2007-03-23 16:42:50 by jwe]
jwe
parents: 6442
diff changeset
76 elseif (topt == "b" || topt == "3")
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
77 options.color = [0, 0, 1];
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
78 elseif (topt == "y")
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
79 options.color = [1, 1, 0];
6444
af8e28709a2c [project @ 2007-03-23 16:42:50 by jwe]
jwe
parents: 6442
diff changeset
80 elseif (topt == "m" || topt == "4")
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
81 options.color = [1, 0, 1];
6444
af8e28709a2c [project @ 2007-03-23 16:42:50 by jwe]
jwe
parents: 6442
diff changeset
82 elseif (topt == "c" || topt == "5")
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
83 options.color = [0, 1, 1];
6444
af8e28709a2c [project @ 2007-03-23 16:42:50 by jwe]
jwe
parents: 6442
diff changeset
84 elseif (topt == "w" || topt == "6")
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
85 options.color = [1, 1, 1];
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
86 elseif (isspace (topt))
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
87 ## Do nothing.
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
88 elseif (topt == ";")
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
89 t = index (opt(2:end), ";");
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
90 if (t)
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
91 options.key = undo_string_escapes (opt(2:t));
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
92 n = t+1;
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
93 else
6459
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
94 if (err_on_invalid)
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
95 error ("%s: unfinished key label", caller);
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
96 else
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
97 valid = false;
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
98 options = __default_plot_options__ ();
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
99 return;
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
100 endif
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
101 endif
3617
b0d6c6e84d56 [project @ 2000-03-21 10:51:38 by jwe]
jwe
parents: 3500
diff changeset
102 else
6459
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
103 if (err_on_invalid)
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
104 error ("%s: unrecognized format character: `%s'", caller, topt);
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
105 else
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
106 valid = false;
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
107 options = __default_plot_options__ ();
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
108 return;
5dc550e1f419 [project @ 2007-03-26 18:11:58 by jwe]
jwe
parents: 6444
diff changeset
109 endif
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
110 endif
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
111 endif
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents: 6146
diff changeset
112 opt(1:n) = [];
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
113 endwhile
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
114
6395
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6264
diff changeset
115 if (have_marker && ! have_linestyle)
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6264
diff changeset
116 options.linestyle = "";
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6264
diff changeset
117 endif
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6264
diff changeset
118
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents:
diff changeset
119 endfunction