octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: meshz, and leading axis handles to mesh, meshc and surface


From: David Bateman
Subject: Re: meshz, and leading axis handles to mesh, meshc and surface
Date: Wed, 28 Nov 2007 22:17:21 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

John W. Eaton wrote:
> On 28-Nov-2007, David Bateman wrote:
> 
> | John W. Eaton wrote:
> | > | Here is a patch that at least addresses this issue for the functions
> | > | that rely on __plt_get_axis_arg__ as the fix was small. Should we
> | > | convert the functions that probe the axes themselves to use
> | > | __plt_get_axis_arg__?
> | >
> | > I think it would be best to use a consistent method, so yes.
> | >
> | > Thanks,
> | >   
> | Then what about something like the attached.. There is one inconsistency
> | with this patch. If you want to do something like "[x,y,z] = sphere()"
> | you don't want a figure at all and therefore the call to gca() in
> | __plt_get_axis_handle__ should be avoided. My solution was to not call
> | gca() in __plt_get_axis_handle__ but rather to return a NaN. Then I
> | adapted axes() to accept a NaN as a valid axis and treat it as a gca().
> | The issue with this is that it is not matlab compatible to accept a NaN
> | to axes().
> | 
> | Can you think of a better solution that doesn't need a lot of special
> | casing in the functions like bar, sphere etc that can return values
> | rather than plot anything?
> 
> I think the following would work as a way to get the handle to the
> current axes if they exist but avoids creating them if not:
> 
>   f = get (0, "currentfigure");
>   if (! isempty (f))
>     h = get (f, 'currentaxes');
>   endif

Yes, thats a nice fix if there is already an axis. Its a good idea to
add this.

> 
> If you have __plt_get_axis_arg__ return the handle in a cell array, or
> return an empty cell array if there is no current axis object, then I
> think you could always write things like
> 
>   surf (ax_arg{:}, x, y, z);
> 
> If ax_arg == {}, then this will be equivalent to
> 
>   surf (x, y, z);
> 
> Does that help, or do you think this solution a bit too convoluted?
> Since using this trick might make the code harder for someone to
> follow later, we should probably add a comment explaining the
> motivation for it in __plt_get_axis_arg__.

That is, as you say rather convoluted, and hard to understand. It also
doesn't handle the majority of cases, which are more like

[h, varargin] = __plt_get_axis_arg__ ("foo", varargin{:});
oldh = gca ();
unwind_protect
  axes(h);
  tmp = someplot(h, varargin{:});
unwind_protect_cleanup
  axes (oldh);
end_unwind_protect

Note that "axes" is called before the plot command. Therefore the issue
has to be handled in axes. Unfortunately "axes" which no arguments
already has another meaning and so "axes(ax_arg{:})" won't be.. I think
I prefer the ax = NaN meaning the current axes as its much simpler.

D.


> 
> jwe
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]