bugGNU Octave - Bugs: bug #53767, error in calling linkaxes

 
 

bug #53767: error in calling linkaxes

Submitter:  avlas <kupiqu>
Submitted:  Fri 27 Apr 2018 04:30:05 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.3.92 Operating System:  * Other
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 27 Apr 2018 07:50:38 PM UTC, comment #11: 


> Yeah, autoranging doesn't work the way one might initially think, i.e., trimming. Instead, it looks at the overall magnitude and attempt to break into whole number intervals like 10/1, 10/2, 10/5, etc.


I am familiar with that and I actually think [0,12] axis for range data in [1,11] is nice.

My point was after wrongly assuming a [0,11] axis for range data in [1,11]... but everything is totally clear now :)

Sorry for the confusion

avlas <kupiqu>
Fri 27 Apr 2018 07:22:54 PM UTC, comment #10: 

Yeah, autoranging doesn't work the way one might initially think, i.e., trimming.  Instead, it looks at the overall magnitude and attempt to break into whole number intervals like 10/1, 10/2, 10/5, etc.

Dan Sebald <sebald>
Fri 27 Apr 2018 06:57:49 PM UTC, comment #9: 

I see.

I think part of my confusion came from thinking that [0,12] corresponded to the second panel, but actually it's for the first. So instead of using the last panel for the link, it uses the first, which makes sense.

Thank you guys for orienting me on this!

avlas <kupiqu>
Fri 27 Apr 2018 06:56:18 PM UTC, comment #8: 

My observation here is that after the first command


>> close all
>> graphics_toolkit qt
>> for ii = 1:3; ha(ii) = subplot(3,1,ii); axes(ha(ii)); plot(randn(10+ii,1)); end
>> get(ha,'xlim')
ans =
{
  [1,1] =

      0   12

  [2,1] =

      0   12

  [3,1] =

      0   14

}

>> linkaxes(ha, 'x')
>> get(ha,'xlim')
ans =
{
  [1,1] =

      0   12

  [2,1] =

      0   12

  [3,1] =

      0   12

}


the first subplot has an x-axis ranging from 0 to 12 via its autoscale.  That would be the first in the series which is subsequently applied to all.  This is true for all graphics toolkits.

Are you seeing something different there?  Is the range of the first subplot 0 to 11 prior to the linkaxes()?

Dan Sebald <sebald>
Fri 27 Apr 2018 06:49:32 PM UTC, comment #7: 

The secondary issue is caused by the order of linking.  Because you are linking the additional axes (ha(2:end)) to the first axes (ha(1)) which has x limits of [0, 12].

At the end of the documentation for linkaxes it specifically mentions this.


When linking, the limits from the first axes in HAX are applied to
the other axes in the list.  Subsequent changes to any one of the
axes will be propagated to the others.


Two examples to see how it works.


## X limit of [0, 12]
for ii = 1:3; ha(ii) = subplot(3,1,ii); axes(ha(ii)); plot(randn(10+ii,1)); end
linkaxes(ha, 'x')



## X limit of [0, 14]
for ii = 1:3; ha(ii) = subplot(3,1,ii); axes(ha(ii)); plot(randn(10+ii,1)); end
linkaxes(flip (ha), 'x')



Rik <rik5>
Group administrator
Fri 27 Apr 2018 06:40:23 PM UTC, comment #6: 


> So the code is behaving according to Octave's documentation.


Mmm, not sure I follow... I fail to understand why if it starts at [0,10+1] and finishes at [0,10+3], it ends up at [0,12] when linkaxes is applied :/

avlas <kupiqu>
Fri 27 Apr 2018 06:34:43 PM UTC, comment #5: 

Regarding the original post and the secondary comment about the range.  The linkaxes() documentation states:


     When linking, the limits from the first axes in HAX are applied to
     the other axes in the list.  Subsequent changes to any one of the
     axes will be propagated to the others.


So the code is behaving according to Octave's documentation.

Dan Sebald <sebald>
Fri 27 Apr 2018 06:24:19 PM UTC, comment #4: 


> Unfortunately the change didn't fix the issue for me


Please disregard this comment. The issue is indeed fixed, but I needed to restart Octave for it to be considered.

avlas <kupiqu>
Fri 27 Apr 2018 05:27:08 PM UTC, comment #3: 

Unfortunately the change didn't fix the issue for me

avlas <kupiqu>
Fri 27 Apr 2018 05:05:55 PM UTC, comment #2: 

I fixed this without noticing this bug report.  See http://hg.savannah.gnu.org/hgweb/octave/rev/2540fde5f07b.  Closing report.

Rik <rik5>
Group administrator
Fri 27 Apr 2018 04:38:46 PM UTC, comment #1: 

The error occurs at the following line in linkprop (with debug_on_error(true)):


81          ## Add listeners to all objects
82          for i = 1 : numel (h)
83            for j = 1 : numel (prop)
84-->              addlistener (h(i), prop{j},
85                           {@cb_sync_prop, [h(1:i-1), h(i+1:end)], prop{j}});
86            endfor
87          endfor


The error occurs at the horizontal concatenation of h(1:i-1) with h(i+1:end). And the problem is that h has been reshaped above somewhere to be a column vector, but here is an attempt to concatenate its parts as a row vector.

So because it's skipping over h(i), this error will only be seen when h contains more than 3 axes references.

The difference from 4.2 is the reshaping of h into a column vector. If that was done for a reason, then this concatenation needs fixing up.

Mike Miller <mtmiller>
Group Member
Fri 27 Apr 2018 04:30:05 PM UTC, original submission:  

There is a regression in linkaxes or linkprop, tested in Octave 4.3.91. Reported to work fine in Octave 4.2.

While this works:


for ii = 1:3; ha(ii) = subplot(3,1,ii); axes(ha(ii)); plot(randn(10+ii,1)); end
linkaxes(ha, 'x')



for ii = 1:3; ha(ii) = subplot(2,2,ii); axes(ha(ii)); plot(randn(10+ii,1)); end
linkaxes(ha, 'x')


This doesn't:


for ii = 1:4; ha(ii) = subplot(4,1,ii); axes(ha(ii)); plot(randn(10+ii,1)); end
linkaxes(ha, 'x')



for ii = 1:4; ha(ii) = subplot(2,2,ii); axes(ha(ii)); plot(randn(10+ii,1)); end
linkaxes(ha, 'x')


This is the error I find:


error: horizontal dimensions mismatch (1x1 vs 2x1)
error: called from
    linkprop at line 84 column 7
    linkaxes at line 83 column 13


Btw, probably not strictly related to this specific issue, but I find intriguing (is this another bug?) that


for ii = 1:3; ha(ii) = subplot(3,1,ii); axes(ha(ii)); plot(randn(10+ii,1)); end
linkaxes(ha, 'x')


shows all x axes limited to [0,12] instead of [0,13].

(Ideally it would be [1,13] for all, but that is certainly another story)

avlas <kupiqu>

 

(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 sebald (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by kupiqu (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-04-27 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
        Release4.3.91 4.3.92
    2018-04-27 mtmiller StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code