bugGNU Octave - Bugs: bug #58436, legend (leg_handle,...

 
 

bug #58436: legend (leg_handle, "boxoff") no longer works

Submitter:  Rik <rik5>
Submitted:  Sun 24 May 2020 02:34:29 AM UTC
   
 
Category:  Octave Function Severity:  4 - Important
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 6.0.90 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 25 May 2020 10:06:45 PM UTC, comment #6: 

Pushed to stable.  Closing report.

Rik <rik5>
Group administrator
Mon 25 May 2020 07:40:54 PM UTC, comment #5: 

The patch works fine and is simple enough that it is safe to push it on stable.

As for the legend properties not being documented, this is more or less bug #57254.

Pantxo Diribarne <pantxo>
Group Member
Mon 25 May 2020 03:25:57 AM UTC, comment #4: 

Attached is a small changeset that adds back the ability to call legend with the first argument being a legend handle.

(file #49165)

Rik <rik5>
Group administrator
Mon 25 May 2020 01:14:17 AM UTC, comment #3: 

I guess I missed the discussion.  My motivating example actually involved two axes, with two legends, on the same figure.  A reduced example is shown below.


hf = figure ();

hax1 = axes;
plot (hax1, 1:10, 'o-b');
hl1 = legend ("axes1 legend");

hax2 = axes ("parent", hf, "position", [0.2, 0.6, 0.3, 0.3]);
plot (hax2, 10:-1:1, 'x-r');
hl2 = legend ("axes2 legend");

## Desired behavior, be able to control legend without switching axes,
## or having to know that legend objects are implemented as axes objects
## and that there is therefore a property "box" that can be changed.
#legend (hl1, 'boxoff')
#legend (hl2, 'boxoff')

## One workaround, switch axes and then use commands
axes (hax1);
legend ('boxoff');
axes (hax2);
legend ('boxoff');

## Second workaround, use axes, rather than legend_handle, as first arg.
legend (hax1, 'boxon');
legend (hax2, 'boxon');


I can work around the issue, but I think it would also be easy to support the old calling syntax.  Let me look at it.

Rik <rik5>
Group administrator
Sun 24 May 2020 04:30:26 PM UTC, comment #2: 

Here is the "discussion":

https://octave.1599824.n4.nabble.com/Octave-specific-legend-call-forms-td4694049.html

Nobody opposed so I did the change.

Pantxo Diribarne <pantxo>
Group Member
Sun 24 May 2020 04:10:12 PM UTC, comment #1: 

@Rik: The call form you mention was Octave specific and can be replaced by:


set (hl1, 'box', 'off')


I am pretty sure it was discussed on the maintainers list but I can't find the discussion ATM. In order to simplify input validation, and because there is a faster and more standard way of doing that, I decided to remove this call form.

Now, this code used to work and I agree that the error message should be clearer and provide a hint on how to fix it. Something
like: "handles to legend axes can't be passed to the legend function. Use @code{set} to manipulate legend properties"


Pantxo Diribarne <pantxo>
Group Member
Sun 24 May 2020 02:34:29 AM UTC, original submission:  

In Octave 5.2 it is possible for the first argument to be a handle to an existing legend object.  The second argument can then be other legend actions such as "boxoff" or "hide".

This no longer works on the stable branch.  The error is obscure


error: legend: objects of type "axes" can't be labeled
error: called from
    legend>parse_opts at line 661 column 7
    legend at line 134 column 8
    tst_leg at line 7 column 1


, but apparently it is because the new code is only looking for an axes handle in the first position.

Test code which is also attached as tst_leg.m is:


graphics_toolkit qt

hf = figure ();
hax1 = axes;
plot (hax1, 1:10, 'o-b');
hl1 = legend ("axes1 legend");
legend (hl1, 'boxoff')



Rik <rik5>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #49165:  58436.cset added by rik5 (4KiB - application/octet-stream)
file #49164:  tst_leg2.m added by rik5 (713B - text/x-matlab)
file #49157:  tst_leg.m added by rik5 (131B - text/x-matlab)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (Submitted the item)
  • -email is unavailable- added by rik5
  •  

    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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-05-25 rik5 StatusPatch Reviewed Fixed
        Open/ClosedOpen Closed
    2020-05-25 pantxo StatusPatch Submitted Patch Reviewed
    2020-05-25 rik5 Attached File- Added 58436.cset, #49165
        StatusConfirmed Patch Submitted
    2020-05-25 rik5 Attached File- Added tst_leg2.m, #49164
    2020-05-24 rik5 Severity3 - Normal 4 - Important
    2020-05-24 rik5 Attached File- Added tst_leg.m, #49157
        Carbon-Copy- Added pantxo

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code