bugGNU Octave - Bugs: bug #37746, 'legend right' squeezes figure to...

 
 

bug #37746: 'legend right' squeezes figure to the left (using 'eastoutside')

Submitter:  Muhali <muhali>
Submitted:  Thu 15 Nov 2012 10:20:21 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
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
   

Sat 17 Aug 2013 01:11:41 AM UTC, comment #4: 

I just verified that the behavior has been fixed; Closing report.

Rik <rik5>
Group administrator
Fri 16 Aug 2013 09:13:33 PM UTC, comment #3: 

This is working for me with both the gnuplot and fltk toolkits.  There have been changes to both legend() and graphics.cc since the last comment, but I don't have any insight into which change fixed this.

In any event, I'm marking this as "ready for test".  If there are no reported problems it can be marked "fixed" and closed.

Ben Abbott <bpabbott>
Group Member
Tue 04 Dec 2012 06:55:20 PM UTC, comment #2: 

I'm going to add Ben to the CC list since he is more of an expert on this piece of code.

The problem seems to be in the large switch statement on position. 


Line 691 of legend.m
case "east"
  if (outside)
    lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3) - ypad, ...
            ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, lpos(3), lpos(4)];
    new_pos = [ca_pos(1), ca_pos(2), ca_pos(3) - lpos(3), ca_pos(4)];
  else
    lpos = [ca_pos(1) + ca_pos(3) - lpos(3) - ypad, ...
            ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, lpos(3), lpos(4)];
  endif


When the legend does not exist, ca_pos and ca_outpos variables work correctly in the equations to resize the current axis to accomodate the legend being placed on the outside.  When the legend already exists, however, the accomodation has already been made but these equations don't take that into account.  Instead they shrink the current axis again.  In fact, there is some recursive updating taking place that I'm not sure is desired.  If I set a breakpoint on the line then it gets executed 3 times for a single call to "legend right".  This seems like overkill.

Rik <rik5>
Group administrator
Tue 04 Dec 2012 05:48:40 AM UTC, comment #1: 

Confirmed on a development tip (12/3/12).  Worse, this is a regression from 3.6.3 which did work correctly.

A simpler piece of code to demonstrate the problem is:


plot (1:10);
legend ("abc", "location", "eastoutside");
legend right


The problem is with the "outside" portion.  If I just use a location of "east" then things work as expected.

Rik <rik5>
Group administrator
Thu 15 Nov 2012 10:20:21 AM UTC, original submission:  

Executing this code, where only 'legend right' is added in the 2nd plot,


subplot(2, 1, 1) ;
plot (1:10, 1:10, 1:10, fliplr (1:10));
title ('Legend with text to the left of key');
legend ({'I am blue', 'I am green'}, 'location', 'eastoutside');
subplot(2, 1, 2) ;
plot (1:10, 1:10, 1:10, fliplr (1:10));
title ('Legend with text to the right of key');
legend ({'I am blue', 'I am green'}, 'location', 'eastoutside');
legend right;
print foo.png


squeezes the entire figure too much to the left. The figure is attached.

Muhali <muhali>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #26915:  foo.png added by muhali (41KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by muhali (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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-08-17 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2013-08-16 bpabbott StatusConfirmed Ready For Test
        Operating SystemGNU/Linux Any
    2013-01-03 rik5 StatusNone Confirmed
    2012-12-04 rik5 Carbon-Copy- Added -email is unavailable-
    2012-12-04 rik5 Item GroupNone Regression
    2012-11-15 muhali Attached File- Added foo.png, #26915

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code