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: John W. Eaton
Subject: Re: meshz, and leading axis handles to mesh, meshc and surface
Date: Wed, 28 Nov 2007 13:04:43 -0500

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

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__.

jwe


reply via email to

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