Mercurial > octave
comparison scripts/plot/private/__pltopt__.m @ 17462:177147bf7b55
Overhaul use of __pltopt__.m to correctly check for cellstr, not just cell.
* scripts/plot/private/__pltopt__.m: Use modern coding conventions. Eliminate
unneeded input checking in subfunctions. Remove unused variables.
* scripts/plot/contourf.m, scripts/plot/feather.m, scripts/plot/plotmatrix.m,
scripts/plot/private/__bar__.m, scripts/plot/private/__quiver__.m,
scripts/plot/private/__scatter__.m, scripts/plot/private/__stem__.m,
scripts/plot/stairs.m: Use iscellstr, not iscell, to properly validate inputs
to __pltopt__.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 23 Sep 2013 08:55:19 -0700 |
parents | 1c89599167a6 |
children | ec5bd610a11f |
comparison
equal
deleted
inserted
replaced
17461:dea415e4216d | 17462:177147bf7b55 |
---|---|
87 ## The legend may be fixed to include the name of the variable | 87 ## The legend may be fixed to include the name of the variable |
88 ## plotted in some future version of Octave. | 88 ## plotted in some future version of Octave. |
89 | 89 |
90 ## Author: jwe | 90 ## Author: jwe |
91 | 91 |
92 function [options, valid] = __pltopt__ (caller, opt, err_on_invalid) | 92 function [options, valid] = __pltopt__ (caller, opt, err_on_invalid = true) |
93 | 93 |
94 options = __default_plot_options__ (); | |
94 valid = true; | 95 valid = true; |
95 options = __default_plot_options__ (); | 96 |
96 | |
97 if (nargin == 2) | |
98 err_on_invalid = true; | |
99 endif | |
100 if (ischar (opt)) | |
101 nel = rows (opt); | |
102 elseif (iscellstr (opt)) | |
103 nel = numel (opt); | |
104 else | |
105 error ("__pltopt__: argument must be a character string or cell array of character strings"); | |
106 endif | |
107 if (ischar (opt)) | 97 if (ischar (opt)) |
108 opt = cellstr (opt); | 98 opt = cellstr (opt); |
109 endif | 99 elseif (! iscellstr (opt)) |
100 error ("__pltopt__: argument must be a character string or cell array of character strings"); | |
101 endif | |
102 | |
103 nel = numel (opt); | |
104 | |
110 for i = nel:-1:1 | 105 for i = nel:-1:1 |
111 [options(i), valid] = __pltopt1__ (caller, opt{i}, err_on_invalid); | 106 [options(i), valid] = __pltopt1__ (caller, opt{i}, err_on_invalid); |
112 if (! err_on_invalid && ! valid) | 107 if (! err_on_invalid && ! valid) |
113 return; | 108 return; |
114 endif | 109 endif |
125 function [options, valid] = __pltopt1__ (caller, opt, err_on_invalid) | 120 function [options, valid] = __pltopt1__ (caller, opt, err_on_invalid) |
126 | 121 |
127 options = __default_plot_options__ (); | 122 options = __default_plot_options__ (); |
128 valid = true; | 123 valid = true; |
129 | 124 |
130 more_opts = 1; | |
131 | |
132 if (! ischar (opt)) | |
133 return; | |
134 endif | |
135 | |
136 have_linestyle = false; | 125 have_linestyle = false; |
137 have_marker = false; | 126 have_marker = false; |
138 | 127 |
139 ## If called by __errplot__, extract the linestyle before proceeding. | 128 ## If called by __errplot__, extract the linestyle before proceeding. |
140 if (strcmp (caller,"__errplot__")) | 129 if (strcmp (caller, "__errplot__")) |
141 if (strncmp (opt, "#~>", 3)) | 130 if (strncmp (opt, "#~>", 3)) |
142 n = 3; | 131 n = 3; |
143 elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2)) | 132 elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2)) |
144 n = 2; | 133 n = 2; |
145 elseif (strncmp (opt, "~", 1) || strncmp (opt, ">", 1) | 134 elseif (strncmp (opt, "~", 1) || strncmp (opt, ">", 1) |