Mercurial > hg > octave-nkf
comparison scripts/plot/util/axes.m @ 19946:b8e4104a8f55
Add the annotation function (bug #43282)
* NEWS: add annotation
* plot.txi: add annotation in same chapter as x/y/zlabel, title...
* __unimplemented__: remove annotation from the list
* scripts/plot/draw/annotation.m: new function file
* axes.m: restack figure children so that the annotation axes is always drawn on top
* axes.m: replace "parent" variable by "cf" for concistency
* clf.m: make "clf" delete the hidden annotation axes for matlab compatibility
* clf.m: avoid flashing a figure in the last test.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Sun, 08 Feb 2015 22:22:28 +0100 |
parents | 4197fc428c7d |
children | 4569903d6c5a |
comparison
equal
deleted
inserted
replaced
19945:ca6fc882177d | 19946:b8e4104a8f55 |
---|---|
57 else | 57 else |
58 ## ARG is axes handle. | 58 ## ARG is axes handle. |
59 htmp = varargin{1}; | 59 htmp = varargin{1}; |
60 if (isscalar (htmp) && isaxes (htmp)) | 60 if (isscalar (htmp) && isaxes (htmp)) |
61 if (__is_handle_visible__ (htmp)) | 61 if (__is_handle_visible__ (htmp)) |
62 parent = ancestor (htmp, "figure"); | 62 cf = ancestor (htmp, "figure"); |
63 set (0, "currentfigure", parent); | 63 set (0, "currentfigure", cf); |
64 set (parent, "currentaxes", htmp); | 64 set (cf, "currentaxes", htmp); |
65 | 65 |
66 ## restack | 66 ## restack |
67 ch = get (parent, "children")(:); | 67 ch = get (cf, "children")(:); |
68 idx = (ch == htmp); | 68 idx = (ch == htmp); |
69 ch = [ch(idx); ch(!idx)]; | 69 ch = [ch(idx); ch(!idx)]; |
70 set (parent, "children", ch); | 70 set (cf, "children", ch); |
71 endif | 71 endif |
72 else | 72 else |
73 error ("axes: H must be a scalar axes handle"); | 73 error ("axes: H must be a scalar axes handle"); |
74 endif | 74 endif |
75 endif | 75 endif |
76 | |
77 ## FIXME: In order to have the overlay axes on top of all other axes | |
78 ## we restack the figure children. Does Matlab use a similar | |
79 ## hack? | |
80 show = get (0, "showhiddenhandles"); | |
81 set (0, "showhiddenhandles", "on"); | |
82 unwind_protect | |
83 ch = get (cf, "children"); | |
84 idx = strcmp (get (ch, "tag"), "scribeoverlay"); | |
85 hover = ch(idx); | |
86 if (! isempty (hover)) | |
87 hax = ch(isaxes (ch)); | |
88 if (numel (hax) > 1) | |
89 ch(isaxes (ch)) = [hover; hax(hax != hover)]; | |
90 set (cf, "children", ch); | |
91 endif | |
92 endif | |
93 unwind_protect_cleanup | |
94 set (0, "showhiddenhandles", show); | |
95 end_unwind_protect | |
76 | 96 |
77 if (nargout > 0) | 97 if (nargout > 0) |
78 h = htmp; | 98 h = htmp; |
79 endif | 99 endif |
80 | 100 |