bugGNU Octave - Bugs: bug #39697, legend doesn't change position if...


bug #39697: legend doesn't change position if title block grows

Submitted by:  Rik <rik5>
Submitted on:  Mon 05 Aug 2013 05:06:54 AM UTC  
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Thu 17 Nov 2016 10:43:24 AM UTC, comment #17:

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

I filed task #14243 about rewriting legend.m

Pantxo Diribarne <pantxo>
Project Member
Sat 18 Jul 2015 04:56:32 PM UTC, comment #16:

Very minor point since they both share code to OpenGL,
the documentation use qt instead of fltk. Hopefully,
the fix will be in common code and fix them both.

Michael Godfrey <godfrey>
Project Member
Sat 18 Jul 2015 02:58:26 PM UTC, comment #15:

FTR, now that fltk is used for generating the documentation we can see that the lack of listener on figure "position" property is also an issue: when printing a figure using a non default size ("paperposition" is changed) the figure position is changed before printing and the legend outline does not fit with the text entries. Simply resizing manually a figure containing a legend shows the issue.
I attached one of the documentation images as generated from a recent build.

(file #34460)

Pantxo Diribarne <pantxo>
Project Member
Fri 30 Aug 2013 01:19:42 AM UTC, comment #14:


I've been thinking about how legends and colorbars can be handled with the recent changes to the axes position, and outerposition properties.

When a legend/colorbox is added outside the plot box, its outerposition can be modified to make room for the new object. The new legend/colorbar object needs to store the original axes position/outerposition value so that when when deleted the axes properties can be restored to their original values.

I think this will be fairly straight forward to implement, but will not be compatible with what Matlab does. Even so, I think it a good approach.

I thought I mention it while now since I'm not sure when/if I'll have time to work on this, and didn't want to risk forgetiing about it.

Ben Abbott <bpabbott>
Project Member
Thu 29 Aug 2013 10:54:03 PM UTC, comment #13:

Adding bug #33112 which mentions that legend has no listener on axis position.

Rik <rik5>
Project Administrator
Fri 16 Aug 2013 05:17:42 AM UTC, comment #12:

I'm going to re-open the bug report because the original issue, the legend box not shifting when the title grows, is still present. The axes is now correctly updated, but there is no listener in legend.m to detect when the axes position has changed and the legend box need to be re-positioned.

Rik <rik5>
Project Administrator
Thu 15 Aug 2013 11:50:26 PM UTC, comment #11:

I pushed the changeset


Ben Abbott <bpabbott>
Project Member
Thu 15 Aug 2013 11:09:24 PM UTC, comment #10:

I thought rundemos() would be enough, but I was obviously wrong. Well, I would go ahead and commit your changeset since that seems to solve the issue with multi-line titles.

Rik <rik5>
Project Administrator
Thu 15 Aug 2013 09:34:10 PM UTC, comment #9:

Rik, try running tests on graphics.cc. With the initial position updates removed, I get the failure below.

Ben Abbott <bpabbott>
Project Member
Thu 15 Aug 2013 09:14:18 PM UTC, comment #8:

Your patch seems to fix things up. I notice that we are now calling update_position once at the start of sync_positions and again at the end. I tried commenting out the first instance and then running through the plot demos and I couldn't see any difference. Perhaps, we don't need the first call anymore? I'm attaching a diff for this change so you can take a look.

(file #28858)

Rik <rik5>
Project Administrator
Thu 15 Aug 2013 04:12:14 PM UTC, comment #7:


I have a simple fix. If you don't notice something I've overlooked, I'll push a changeset.

(file #28855)

Ben Abbott <bpabbott>
Project Member
Thu 15 Aug 2013 01:03:13 AM UTC, comment #6:

Apparently the problem isn't the menubar or statusbar height. Try the following

It appears that the extents of the title are lagging by one update. Which may imply there is an easy fix. Maybe an additional mark_modified () is all that is needed. For example, the commands below render the desired result.

Ben Abbott <bpabbott>
Project Member
Wed 14 Aug 2013 10:01:06 PM UTC, comment #5:

Maybe the 20 pixels is due to the status bar?

Ben Abbott <bpabbott>
Project Member
Wed 14 Aug 2013 09:35:16 PM UTC, comment #4:

I see you're right that the axes position is being shifted to have "two" remain visible. Interestingly, I switched over to pixel for the units and everything looks right if I bring the axes and title text object down by 20 pixels. This could, of course, just be a coincidence. But it might also suggest that we aren't calculating correctly with the menubar height somehow. I did tests with the menubar turned off though and the title is still being clipped.

Rik <rik5>
Project Administrator
Wed 14 Aug 2013 08:50:21 PM UTC, comment #3:

Yeah, there are plenty of short comings for the legend. It really needs to be rewritten from scratch. But before that is done, I hope the updating for the tightinset can be fixed.

The problem with tightinset is that calc_tightbox() doesn't account for changes to the axes fontsize. In addition there are problems with changes to the title, and {x,y,z}labels. However, I don't think the problem is a missing mark_modified ().

If you try the following commands, you'll see that "one" will disappear as it moves above the top of the figure, but that "two" is always visible. So the updating appears to be working. Perhaps the height or position of the title isn't correct?

Ben Abbott <bpabbott>
Project Member
Wed 14 Aug 2013 08:11:35 PM UTC, comment #2:

The axes position not moving is an issue by itself. It seems like we are missing a drawnow() or mark_modified() call after adding the multi-line title. You could file another bug report for that.

But, it doesn't affect this issue which is that there is no listener on the axes position. If I use the mouse on a corner of the plot window to slightly resize it then the axes is re-drawn with the correct size, but nothing fires to also adjust the legend box position.

Incidentally, "fontunits" only determines how "fontsize" will be interpreted. To find the extents for the title you need to operate with the "units" property on the title text object.

Rik <rik5>
Project Administrator
Wed 14 Aug 2013 12:11:55 PM UTC, comment #1:


The tightinset support has been improved in the last few weeks. So, I tried your example to see if there was any improvement. The first thing I noticed was that the axes position didn't move. Is that a regression?

Second, it looks to me as if the title's text object's extent isn't being updated properly.

The title's extent appears to indicate the text object is only one line high. Which explains why the tightinset isn't being updated correctly?

Ben Abbott <bpabbott>
Project Member
Mon 05 Aug 2013 05:06:54 AM UTC, original submission:

There isn't a listener on the the position property of the axis. If the axis changes position, such as when the title block grows, the legend is left out of position. This is apparently a known problem. In the code for legend.m I find:

I'm adding a %!demo block to legend.m which shows the problem.

Rik <rik5>
Project Administrator


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

Attach File(s):

Attached Files
file #34460:  splinefit1.png added by pantxo (48KiB - image/png)
file #28858:  graphics2.diff added by rik5 (874B - application/x-download)
file #28855:  graphics.diff added by bpabbott (363B - application/octet-stream)


   bug dependencies.

   bug dependencies.


Carbon-Copy List
  • -unavailable- added by godfrey (Posted a comment)
  • -unavailable- added by pantxo (Updated the item)
  • -unavailable- added by bpabbott (Posted a comment)
  • -unavailable- added by rik5 (Submitted the item)
  • -unavailable- added by rik5

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 13 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 18 Oct 2016 08:26:38 PM UTCpantxoDependencies-=>bugs #49382 is dependent
    Sat 18 Jul 2015 02:58:26 PM UTCpantxoAttached File-=>Added splinefit1.png, #34460
    Sat 25 Apr 2015 05:38:13 AM UTCrik5Dependencies-=>bugs #43067 is dependent
    Sat 31 Aug 2013 08:17:18 PM UTCbpabbottAssigned tobpabbott=>None
    Thu 29 Aug 2013 10:54:03 PM UTCrik5Dependencies-=>Depends on bugs #33112
    Fri 16 Aug 2013 05:17:42 AM UTCrik5StatusFixed=>Confirmed
    Thu 15 Aug 2013 11:50:26 PM UTCbpabbottStatusNone=>Fixed
      Assigned toNone=>bpabbott
    Thu 15 Aug 2013 09:14:18 PM UTCrik5Attached File-=>Added graphics2.diff, #28858
    Thu 15 Aug 2013 04:12:14 PM UTCbpabbottAttached File-=>Added graphics.diff, #28855
    Mon 05 Aug 2013 05:06:54 AM UTCrik5Carbon-Copy-=>Added -unavailable-

    Back to the top

    Powered by Savane 3.1-cleanup1