bugGNU Octave - Bugs: bug #39395, legend spacing ignores fontsize

 
 

bug #39395: legend spacing ignores fontsize

Submitter:  Ben Abbott <bpabbott>
Submitted:  Tue 02 Jul 2013 09:45:50 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Fixed Assigned to:  rik5
Originator Name:  Ben Abbott Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 08 Oct 2013 12:10:04 PM UTC, comment #2: 

I did a couple of quick tests. You change works for me on MacOS X.  I'm closing it.

Ben Abbott <bpabbott>
Group Member
Tue 08 Oct 2013 04:44:55 AM UTC, comment #1: 

Independent of this bug report, I re-wrote legend to do basically what you suggested.  Any property which could affect the amount of space taken up by the text labels, such as 'fontsize' or 'fontunits', causes the legend to be reconstructed.  It appears to work okay for printing with the FLTK toolkit though.  Do you want to keep this report open?

Rik <rik5>
Group administrator
Tue 02 Jul 2013 09:45:50 AM UTC, original submission:  

The 1st demo for legend.m is


clf;
 plot (rand (2));
 title ('legend called with cellstr and string inputs for labels');
 h = legend ({'foo'}, 'bar');
 legend location northeastoutside
 set (h, 'fontsize', 20);


The resulting fontsize is correct for both the gnuplot and fltk toolkits, but the line spacing between the legend's keys does not change.  The result is that the keys are too close together.

To fix this the entire legend must be reconstructed.  Unfortunately, if the fontsize listener is modified to @updatelegend the key objects are deleted and replace by new ones.  This introduces problems for the print command which attempt to temporarily modified the fontsize of all objects.  Which is a problem if the same objects do not exist when print() attempt to return the fontsizes to their original values.

Also, replace key objects is inconsistent with Matlab, as is demonstrated below.


close all
plot (rand (3))
hl = legend ({'blue', 'green', 'red'});
userdata = get (hl, 'UserData')

userdata =

        PlotHandle: 173.1833
         legendpos: 1
    LegendPosition: [0.7406 0.7786 0.1562 0.1292]
      LabelHandles: [9x1 double]
           handles: [3x1 double]
          lstrings: {3x1 cell}
      LegendHandle: 181.1833

set (hl, 'fontsize', 20)
userdata2 = get (hl, 'UserData');
isequal (userdata.LabelHandles, userdata2.LabelHandles)

ans = 1


A rewrite of legend() looks to be needed.  In doing so, it wouldn't hurt to copy the info Mathworks saves to the legend's userdata property.

Ben Abbott <bpabbott>
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 bpabbott (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-08 bpabbott StatusNone Fixed
        Assigned toNone rik5
        Open/ClosedOpen Closed
    2013-08-16 bpabbott Assigned tobpabbott None
    2013-07-19 bpabbott Assigned toNone bpabbott

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code