1 ## Copyright (C) 1994-2012 John W. Eaton
3 ## This file is part of Octave.
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.
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.
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/>.
20 ## @deftypefn {Function File} {} __pltopt__ (@var{caller}, @var{opt})
21 ## Undocumented internal function.
24 ## @deftypefn {Function File} {} __pltopt__ (@var{caller}, @var{opt})
26 ## Decode plot option strings.
28 ## @var{opt} can currently be some combination of the following:
32 ## For solid linestyle (default).
35 ## For dashed line style.
38 ## For linespoints plot style.
41 ## For dots plot style.
56 ## Magenta line color.
68 ## Here @code{"title"} is the label for the key.
83 ## Used in combination with the points or linespoints styles, set the point
87 ## The legend may be fixed to include the name of the variable
88 ## plotted in some future version of Octave.
92 function [options, valid] = __pltopt__ (caller, opt, err_on_invalid)
95 options = __default_plot_options__ ();
97 if ((nargin == 2 || nargin == 3) && (nargout == 1 || nargout == 2))
99 err_on_invalid = true;
103 elseif (iscellstr (opt))
106 error ("__pltopt__: expecting argument to be character string or cell array of character strings");
112 [options(i), valid] = __pltopt1__ (caller, opt{i}, err_on_invalid);
113 if (! err_on_invalid && ! valid)
123 ## Really decode plot option strings.
125 ## Author: Rick Niles <niles@axp745.gsfc.nasa.gov>
129 function [options, valid] = __pltopt1__ (caller, opt, err_on_invalid)
131 options = __default_plot_options__ ();
136 if (nargin != 2 && nargin != 3)
144 have_linestyle = false;
147 ## If called by __errplot__, extract the linestyle before proceeding.
148 if (strcmp (caller,"__errplot__"))
149 if (strncmp (opt, "#~>", 3))
151 elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2))
153 elseif (strncmp (opt, "~", 1) || strncmp (opt, ">", 1)
154 || strncmp (opt, "#", 1))
159 options.errorstyle = opt(1:n);
162 options.errorstyle = "~";
165 while (! isempty (opt))
166 if (strncmp (opt, "--", 2) || strncmp (opt, "-.", 2))
167 options.linestyle = opt(1:2);
168 have_linestyle = true;
173 if (topt == "-" || topt == ":")
174 have_linestyle = true;
175 options.linestyle = topt;
176 elseif (topt == "+" || topt == "o" || topt == "*"
177 || topt == "." || topt == "x" || topt == "s"
178 || topt == "d" || topt == "^" || topt == "v"
179 || topt == ">" || topt == "<" || topt == "p"
180 || topt == "h" || topt == "@")
182 ## Backward compatibility. Leave undocumented.
186 options.marker = topt;
187 ### Numeric color specs for backward compatibility. Leave undocumented.
188 elseif (topt == "k" || topt == "0")
189 options.color = [0, 0, 0];
190 elseif (topt == "r" || topt == "1")
191 options.color = [1, 0, 0];
192 elseif (topt == "g" || topt == "2")
193 options.color = [0, 1, 0];
194 elseif (topt == "b" || topt == "3")
195 options.color = [0, 0, 1];
197 options.color = [1, 1, 0];
198 elseif (topt == "m" || topt == "4")
199 options.color = [1, 0, 1];
200 elseif (topt == "c" || topt == "5")
201 options.color = [0, 1, 1];
202 elseif (topt == "w" || topt == "6")
203 options.color = [1, 1, 1];
204 elseif (isspace (topt))
207 t = index (opt(2:end), ";");
209 options.key = undo_string_escapes (opt(2:t));
213 error ("%s: unfinished key label", caller);
216 options = __default_plot_options__ ();
222 error ("%s: unrecognized format character: `%s'", caller, topt);
225 options = __default_plot_options__ ();
233 if (! have_linestyle && have_marker)
234 options.linestyle = "none";
237 if (have_linestyle && ! have_marker)
238 options.marker = "none";