Mercurial > hg > octave-lyh
comparison scripts/plot/axes.m @ 17042:62d5f73e840c
axes.m: reorder figure children after setting the currentaxes (bug #39539).
* scripts/plot/axes.m:
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Sat, 20 Jul 2013 16:05:44 +0200 |
parents | 5d3a684236b0 |
children | eaab03308c0b |
comparison
equal
deleted
inserted
replaced
17041:1b549a0c3ca4 | 17042:62d5f73e840c |
---|---|
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} axes () | 20 ## @deftypefn {Function File} {} axes () |
21 ## @deftypefnx {Function File} {} axes (@var{property}, @var{value}, @dots{}) | 21 ## @deftypefnx {Function File} {} axes (@var{property}, @var{value}, @dots{}) |
22 ## @deftypefnx {Function File} {} axes (@var{h}) | 22 ## @deftypefnx {Function File} {} axes (@var{h}) |
23 ## Create an axes object and return a handle to it. | 23 ## @deftypefnx {Function File} {@var{h} =} axes (@dots{}) |
24 ## Create an axes object and return a handle to it, or set the current | |
25 ## axes to @var{h}. | |
26 ## | |
27 ## Called without any arguments, or with @var{property}/@var{value} pairs, | |
28 ## contruct a new axes. For accepted properties and corresponding | |
29 ## values, see @code{set} function. | |
30 ## | |
31 ## Called with a single axes handle argument @var{h}, the function makes | |
32 ## @var{h} the current axis. It also restacks the axes in the | |
33 ## corresponding figure so that @var{h} is the first entry in the list | |
34 ## of children. This causes @var{h} to be displayed on top of any other | |
35 ## axes objects (Z-order stacking). | |
36 ## | |
37 ## @seealso {gca, set, get} | |
24 ## @end deftypefn | 38 ## @end deftypefn |
25 | 39 |
26 ## Author: jwe | 40 ## Author: jwe |
27 | 41 |
28 function h = axes (varargin) | 42 function h = axes (varargin) |
34 cf = varargin{2*idx}; | 48 cf = varargin{2*idx}; |
35 varargin([2*idx-1, 2*idx]) = []; | 49 varargin([2*idx-1, 2*idx]) = []; |
36 else | 50 else |
37 cf = gcf (); | 51 cf = gcf (); |
38 endif | 52 endif |
39 tmp = __go_axes__ (cf, varargin{:}); | 53 htmp = __go_axes__ (cf, varargin{:}); |
40 if (__is_handle_visible__ (tmp)) | 54 if (__is_handle_visible__ (htmp)) |
41 set (ancestor (cf, "figure"), "currentaxes", tmp); | 55 set (ancestor (cf, "figure"), "currentaxes", htmp); |
42 endif | 56 endif |
43 else | 57 else |
44 ## arg is axes handle. | 58 ## ARG is axes handle. |
45 tmp = varargin{1}; | 59 htmp = varargin{1}; |
46 if (length (tmp) == 1 && ishandle (tmp) | 60 if (isscalar (htmp) && ishandle (htmp) |
47 && strcmp (get (tmp, "type"), "axes")) | 61 && strcmp (get (htmp, "type"), "axes")) |
48 if (__is_handle_visible__ (tmp)) | 62 if (__is_handle_visible__ (htmp)) |
49 parent = ancestor (tmp, "figure"); | 63 parent = ancestor (htmp, "figure"); |
50 set (0, "currentfigure", parent); | 64 set (0, "currentfigure", parent); |
51 set (parent, "currentaxes", tmp); | 65 set (parent, "currentaxes", htmp); |
66 | |
67 ## restack | |
68 ch = get (parent, "children")(:); | |
69 idx = (ch == htmp); | |
70 ch = [ch(idx); ch(!idx)]; | |
71 set (parent, "children", ch); | |
52 endif | 72 endif |
53 else | 73 else |
54 error ("axes: expecting argument to be a scalar axes handle"); | 74 error ("axes: H must be a scalar axes handle"); |
55 endif | 75 endif |
56 endif | 76 endif |
57 | 77 |
58 if (nargout > 0) | 78 if (nargout > 0) |
59 h = tmp; | 79 h = htmp; |
60 endif | 80 endif |
61 | 81 |
62 endfunction | 82 endfunction |