bugGNU Octave - Bugs: bug #41142, change to legend deletes and...

 
 

bug #41142: change to legend deletes and recreates text objects

Submitter:  Ben Abbott <bpabbott>
Submitted:  Tue 07 Jan 2014 11:48:44 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
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
   

Mon 18 Nov 2019 08:47:53 PM UTC, comment #5: 

Verified with new legend.m.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Mon 18 Nov 2019 09:47:51 AM UTC, comment #4: 

legend.m has been rewritten (for OpenGL toolkits only). This bug should now be fixed.

Marking ready for test.

Pantxo Diribarne <pantxo>
Group Member
Thu 17 Nov 2016 10:40:41 AM UTC, comment #3: 

This bug is still present in the current dev 4.3.0 (39f39eb4e476).

I filed task #14243 about rewriting legend.m

Pantxo Diribarne <pantxo>
Group Member
Thu 09 Jan 2014 12:47:17 AM UTC, comment #2: 

I agree the legend code needs to be rewritten with Matlab compatibility in mind.  Not a simple task.

Ben Abbott <bpabbott>
Group Member
Wed 08 Jan 2014 02:49:09 AM UTC, comment #1: 

Matlab's legend function is really hard to mimic exactly.  As you know, we use an axes object to represent the legend and the object has extra properties beyond a regular axes object such as fontsize.  We add listener's on the axes object for these special properties so that if the legend object is changed all of the child objects are updated.  So, one way to make this work is just to use this interface.


clf ()
plot (rand (2))
hleg = legend ({"foo", "bar"});
set (hleg, 'fontsize', 16);


The other way to get this to work is to sort handles so that the axes objects are last.


set (h(! isaxes (h)), 'fontsize', 16)
set (h(isaxes (h)), 'fontsize', 16)


We currently destroy the legend axes object when the fontsize changes because we need to re-calculate the size of the box which will fit the new text.  If you can see a better way then we can implement it, but it looks daunting.

Rik <rik5>
Group administrator
Tue 07 Jan 2014 11:48:44 PM UTC, original submission:  

With Matlab, the example below does not throw an error


clf ()
plot (rand (2))
legend ({"foo", "bar"})
h = findobj (gcf (), "-property", "fontsize")
h =

  -21.712
  -28.956
  -15.743
  -16.340
get (h, "type")
ans =
{
  [1,1] = axes
  [2,1] = axes
  [3,1] = text
  [4,1] = text
}
get (h(3:end), 'string')
ans =
{
  [1,1] = bar
  [2,1] = foo
}
set (h, "fontsize", 16)
error: set: invalid handle (= -15.7428)
error: called from:


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

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -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
    2019-11-18 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-11-18 pantxo StatusConfirmed Ready For Test
    2014-08-08 rik5 StatusNone Confirmed
    2014-08-08 rik5 Dependencies- bugs #42940 is dependent

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code