Mercurial > hg > octave-nkf
changeset 17013:64d603f8bcd9
__get_axis_args.m: search for 'parent' in property/value pairs and use it as fall back axes.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Fri, 19 Jul 2013 00:53:11 +0200 |
parents | 942d892524b3 |
children | 4d9862d9fce5 |
files | scripts/plot/__plt_get_axis_arg__.m |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/__plt_get_axis_arg__.m +++ b/scripts/plot/__plt_get_axis_arg__.m @@ -33,6 +33,11 @@ nogca = false; endif + + ## Search for parent property + charargs = cellfun (@ischar,varargin); + isparent = strcmp (lower (varargin(charargs)), "parent"); + ## Figure handles are integers, but object handles are non-integer, ## therefore ignore integer scalars. if (nargin > 1 && length (varargin) > 0 && isnumeric (varargin{1}) @@ -50,6 +55,22 @@ else error ("%s: expecting first argument to be axes handle", caller); endif + elseif (numel (varargin) > 1 && any (isparent)) + tmp = find (charargs); + idx = tmp(isparent)(1); + if (idx < numel (varargin) && ishandle (varargin{idx+1})) + tmp = varargin{idx+1}; + obj = get (tmp); + if ((strcmp (obj.type, "axes") && ! strcmp (obj.tag, "legend")) + || strcmp (obj.type, "hggroup")) + h = ancestor (tmp, "axes"); + varargin(idx:idx+1) = []; + else + error ("%s: expecting parent value to be axes handle", caller); + endif + else + error ("%s: expecting parent value to be axes handle", caller); + endif else f = get (0, "currentfigure"); if (isempty (f))