Mercurial > hg > octave-nkf
comparison scripts/plot/hold.m @ 17125:b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
* scripts/geometry/voronoi.m, scripts/image/imagesc.m,
scripts/plot/__plt_get_axis_arg__.m, scripts/plot/axes.m, scripts/plot/cla.m,
scripts/plot/colorbar.m, scripts/plot/hold.m, scripts/plot/legend.m,
scripts/plot/plotmatrix.m, scripts/plot/plotyy.m,
scripts/plot/private/__errplot__.m, scripts/plot/private/__plt__.m,
scripts/plot/view.m: Use new isaxes function to simplify code.
* scripts/plot/shading.m: Use Octave convention for spacing of parentheses.
* scripts/plot/zlabel.m: Correct %!test incorrectly calling plot3 with figure
handle.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 31 Jul 2013 16:27:49 -0700 |
parents | eaab03308c0b |
children | df4c4b7708a4 |
comparison
equal
deleted
inserted
replaced
17124:7649779e6ebd | 17125:b5d6314314fc |
---|---|
42 ## | 42 ## |
43 ## @item hold | 43 ## @item hold |
44 ## Toggle the current hold state. | 44 ## Toggle the current hold state. |
45 ## @end table | 45 ## @end table |
46 ## | 46 ## |
47 ## If the first argument @var{hax} is an axes handle, | |
48 ## rather than the current axes returned by @code{gca}. | |
49 ## | |
50 ## When given the additional argument @var{hax}, the hold state is modified | 47 ## When given the additional argument @var{hax}, the hold state is modified |
51 ## for this axis rather than the current axes returned by @code{gca}. | 48 ## for this axis rather than the current axes returned by @code{gca}. |
52 ## | 49 ## |
53 ## To query the current hold state use the @code{ishold} function. | 50 ## To query the current hold state use the @code{ishold} function. |
54 ## @seealso{ishold, cla, clf, newplot} | 51 ## @seealso{ishold, cla, clf, newplot} |
55 ## @end deftypefn | 52 ## @end deftypefn |
56 | 53 |
57 function hold (varargin) | 54 function hold (varargin) |
58 | 55 |
59 if (nargin > 0 && isscalar (varargin{1}) && ishandle (varargin{1}) | 56 if (nargin > 0 && isscalar (varargin{1}) && isaxes (varargin{1})) |
60 && strcmp (get (varargin{1}, "type"), "axes")) | 57 hax = vargin{1}; |
61 [hax, varargin, nargs] = __plt_get_axis_arg__ ("hold", varargin{:}); | 58 varargin(1) = []; |
62 if (isempty (hax)) | 59 nargs = numel (varargin); |
63 hax = gca (); | |
64 endif | |
65 ## FIXME: Should this be ancestor (hax, "parent")? | 60 ## FIXME: Should this be ancestor (hax, "parent")? |
66 hfig = get (hax, "parent"); | 61 hfig = get (hax, "parent"); |
67 elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1})) | 62 elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1})) |
68 print_usage (); | 63 print_usage (); |
69 else | 64 else |
74 | 69 |
75 hold_all = false; | 70 hold_all = false; |
76 if (nargs == 0) | 71 if (nargs == 0) |
77 turn_hold_off = ishold (hax); | 72 turn_hold_off = ishold (hax); |
78 elseif (nargs == 1) | 73 elseif (nargs == 1) |
79 state = varargin{1}; | 74 state = tolower (varargin{1}); |
80 if (ischar (state)) | 75 switch (state) |
81 if (strcmpi (state, "off")) | 76 case "off" |
82 turn_hold_off = true; | 77 turn_hold_off = true; |
83 elseif (strcmpi (state, "all")) | 78 case "all" |
84 turn_hold_off = false; | 79 turn_hold_off = false; |
85 hold_all = true; | 80 hold_all = true; |
86 elseif (strcmpi (state, "on")) | 81 case "on" |
87 turn_hold_off = false; | 82 turn_hold_off = false; |
88 else | 83 otherwise |
89 error ("hold: invalid hold STATE"); | 84 error ("hold: invalid hold STATE"); |
90 endif | 85 endswitch |
91 endif | |
92 else | 86 else |
93 print_usage (); | 87 print_usage (); |
94 endif | 88 endif |
95 | 89 |
96 if (turn_hold_off) | 90 if (turn_hold_off) |