octave-maintainers
[Top][All Lists]
Advanced

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

additional plotyy observation (was: Re: automated (or otherwise) tests f


From: John W. Eaton
Subject: additional plotyy observation (was: Re: automated (or otherwise) tests for graphics code?)
Date: Sat, 18 Oct 2008 00:49:16 -0400

On 17-Oct-2008, John W. Eaton wrote:

| On 17-Oct-2008, John W. Eaton wrote:
| 
| | On 17-Oct-2008, David Bateman wrote:
| | 
| | | David Bateman wrote:
| | | > John W. Eaton wrote:
| | | >> We seem to be having a lot of regressions in the graphics code
| | | >> lately, so maybe it is time to start thinking of some way to provide
| | | >> tests for these functions.  
| | | >
| | | > Hey progress is making a different mistake -)
| | | 
| | | I applied the attached patch that fixes a few more of the plotting 
problems
| | 
| | Thanks.
| | 
| | With your patch, I currently see these remaining demo failures
| | 
| | [...]
| 
| OK, I see that some of these demos work when run by themselves in a
| fresh Octave session, but they fail when run sequentially in the same
| session.
| 
| This failure:
| 
| | /home/jwe/src/octave/scripts/plot/plotyy.m example 1:
| |    x = 0:0.1:2*pi; 
| |    y1 = sin (x);
| |    y2 = exp (x - 1);
| |    ax = plotyy (x, y1, x - 1, y2, @plot, @semilogy);
| |    xlabel ("X");
| |    ylabel (ax(1), "Axis 1");
| |    ylabel (ax(2), "Axis 2");
| | 
| |   /home/jwe/src/octave/scripts/plot/plotyy.m example 1: failed
| |   axes: expecting argument to be a scalar axes handle
| 
| Seems to cause a series of other problems.  I can duplicate the
| problem above with something as simple as:
| 
|   octave:1> plotyy ([0,1], [0,1], [1,2], [1,2], @plot, @plot);
|   octave:2> plotyy ([0,1], [0,1], [1,2], [1,2], @plot, @plot);
|   Stopped in:
| 
|   --> plotyy>deleteplotyy at line 188 column 5
|       newplot at line 49 column 2
|       plotyy>__plotyy__ at line 130 column 3
|       plotyy at line 102 column 19
|   tmp = -1.2364
|   error: axes: expecting argument to be a scalar axes handle
|   error: called from:
|   error:   /home/jwe/src/octave/scripts/plot/axes.m at line 56, column 7
|   error:   /home/jwe/src/octave/scripts/plot/plotyy.m at line 138, column 3
|   error:   /home/jwe/src/octave/scripts/plot/plotyy.m at line 104, column 5
| 
| In the above, I've inserted a call to dbstack at in the
| "plotyy>deleteplotyy" function.  The problem seems to be that the
| deletefcn callback is called and deletes an axes object when it should
| not.  Is newplot doing the right thing?  Should some function be
| clearing the deletefcn callback?  I don't understand how all of these
| functions are intended to work, so I could use some help with fixing
| this problem.

OK, I now see that these deletefcn callbacks:

  ## Add invisible text objects that when destroyed, 
  ## also remove the other axis
  t1 = text (0, 0, "", "parent", ax(1), "tag", "plotyy", 
             "handlevisibility", "off", "visible", "off",
             "xliminclude", "off", "yliminclude", "off");
  t2 = text (0, 0, "", "parent", ax(2), "tag", "plotyy", 
             "handlevisibility", "off", "visible", "off",
             "xliminclude", "off", "yliminclude", "off");

  set (t1, "deletefcn", address@hidden, ax(2), t2});
  set (t2, "deletefcn", address@hidden, ax(1), t1});

are causing trouble in the __plotyy__ subfunction because it does
this:

  axes (ax(1));
  newplot ();
  h1 = feval (fun1, x1, y1);

  set (ax(1), "ycolor", getcolor (h1(1)));
  set (ax(1), "xlim", xlim);

  cf = gcf ();
  set (cf, "nextplot", "add");
  axes (ax(2));
  newplot ();

and when the first newplot is called for ax(1), it deletes the
children of the current axes, so that triggers the deletefcn which
destroys ax(2).  Then the subsequent call to axes fails becuase ax(2)
is no longer valid.  This only happens if there is already a plotyy
plot on the screen which has the deletefcn functions defined.  So I
think that's why it works every other time.

Adding an additional call to newplot at the beginning of plotyy seems
to avoid the problem.  But in that case, is it really necessary to
have the additional calls to newplot in __plotyy__ for each axes
object?

However, there is still something funny going on.  After adding the
additional call to newplot, repeated calls to plotyy seem to work OK,
but the sequence

  demo plotyy
  demo quiver3

fails with

  octave:1> demo plotyy
  plotyy example 1:
   x = 0:0.1:2*pi; 
   y1 = sin (x);
   y2 = exp (x - 1);
   ax = plotyy (x, y1, x - 1, y2, @plot, @semilogy);
   xlabel ("X");
   ylabel (ax(1), "Axis 1");
   ylabel (ax(2), "Axis 2");

  octave:2> demo quiver3
  quiver3 example 1:
   [x,y]=meshgrid (-1:0.1:1); 
   z=sin(2*pi*sqrt(x.^2+y.^2)); 
   theta=2*pi*sqrt(x.^2+y.^2)+pi/2;
   quiver3(x,y,z,sin(theta),cos(theta),ones(size(z)));
   hold on; 
   mesh(x,y,z); 
   hold off;

  quiver3 example 1: failed
  get: invalid handle (= -1.87123)Press <enter> to continue: 
  quiver3 example 2:
   [x, y, z] = peaks (25);
   surf (x, y, z);
   hold on;
   [u, v, w] = surfnorm (x, y, z / 10);
   h = quiver3 (x, y, z, u, v, w);
   set (h, "maxheadsize", 0.33);

  quiver3 example 2: failed
  get: invalid handle (= -1.87123)error: get: invalid handle (= -16.0148)
  error: called from:
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_axes__.m at line 60, 
column 9
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_figure__.m at line 56, 
column 8
  error:   /home/jwe/src/octave/scripts/plot/gnuplot_drawnow.m at line 68, 
column 5

So I guess I'm still a bit lost here.

jwe


reply via email to

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