bugGNU Octave - Bugs: bug #42285, linkprop doesn't always work with...

 
 

bug #42285: linkprop doesn't always work with axes limits

Submitter:  Pantxo Diribarne <pantxo>
Submitted:  Sun 04 May 2014 08:36:12 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 30 May 2014 10:08:15 AM UTC, comment #6: 

What about adding an argument to addlistener? This argument could be a list of handles of objects that are necessary for the listener function to work.
Then addlistener could feed the deletfcn callback list of those objects with the appropriate dellistener function. Not sure my explanation is clear so here is an example in which changing the linewidth of the axes would change the linewidth of its line children:


ax = axes ();
li = line (1:10, 1:10);
update_width = @(h, dummy, hline) set (hline, "linewidth", get (h, "linewidth"));
addlistener (ax, "linewidth", {@update_width, li}, li) ## note the fourth argument


The fourth argument simply adds "dellistener (ax, "linewidth", {@update_width, li})" to li's deletefcn callback list.

Pantxo Diribarne <pantxo>
Group Member
Mon 19 May 2014 03:07:26 PM UTC, comment #5: 

Your example does produce an error.  Actually, I think polar needs to be overhauled anyways because the first two commands don't work either.


polar(...)
cla


In this case the hggroup which defines the polar grid is left in place.

This piece of code is also imperfect:


plot (1:10)
legend abc
cla


Because the legend object is implemented as another axis of the figure it isn't cleared when the first axis is.

Rik <rik5>
Group administrator
Sat 17 May 2014 10:23:52 AM UTC, comment #4: 

Among the repercussions I can see, any listenner that is added to an axes (or figure) should be accompanied by a deletefcn that dellistener. For example, I suspect the new polar grid, that inherits some of its parent axes properties, will leave out-dated listeners onces deleted (can't test it at the moment as I can't pull). The following code should then throw errors:


polar (...)
cla
plot (1:10)


Pantxo Diribarne <pantxo>
Group Member
Fri 16 May 2014 03:20:48 PM UTC, comment #3: 

This was pretty easy to fix, although I guess we should make sure there are no other repercussions.  In graphics.in.h, there is this piece of code:


void set_defaults (const std::string& mode)
{
  remove_all_listeners ();
  xproperties.set_defaults (*this, mode);
}


I simply took out the remove_all_listeners() function call and then Octave works the same as Matlab.  I verified that your sample piece of code works with that change.

The only way to get rid of a listener now is to explicitly delete it with dellistener or destroy the axes object with delete (gca).

The changeset is here (http://hg.savannah.gnu.org/hgweb/octave/rev/10082673a8f0).

Rik <rik5>
Group administrator
Fri 16 May 2014 12:57:01 PM UTC, comment #2: 

Yes, the example works in matlab. The "plot" command doesn't remove axes listeners, neither does "reset" (AFAIU "cla reset" is equivalent to "reset (gca)") command:


ax1 = subplot (1,2,1);
ax2 = subplot (1,2,2);
link = linkprop ([ax1 ax2], 'ylim');
reset (ax1)
set (ax2, 'ylim', [-5 5])
get (ax1, 'ylim') %% -> [-5 5]


I should probably consider this in order to update my patch for bug #35511.

Pantxo Diribarne <pantxo>
Group Member
Thu 15 May 2014 09:33:12 PM UTC, comment #1: 

Does the example code work in Matlab?  I would expect the final call to plot (1:10) would call newplot() which in turn would reset the axes to a default state including destroying any listeners.  If I mimic that sequence then I do get exactly what Octave does.


ax1 = subplot (1,2,1);
ax2 = subplot (1,2,2);
link = linkprop ([ax1 ax2], "ylim");
set (ax1, "ylim", [-5 2]) ## ax2 is updated as expected
cla reset;  # This is what newplot would do
set (ax2, "ylim", [1 10]) # only ax2 is updated


Rik <rik5>
Group administrator
Sun 04 May 2014 08:36:12 PM UTC, original submission:  

The following example demonstrates the bug


ax1 = subplot (1,2,1);
ax2 = subplot (1,2,2);
link = linkprop ([ax1 ax2], "ylim");
set (ax1, "ylim", [-5 2]) ## ax2 is updated as expected
plot (1:10)               ## ax1 is not updated


Explicitly changing "ylim" works, but when the "ylim" of an axes is updated due to a data change, "ylim" value is not propagated to the other axes.

Pantxo Diribarne <pantxo>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-05-16 rik5 StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2014-05-15 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code