bugGNU Octave - Bugs: bug #42034, legend () call should not create...

 
 

bug #42034: legend () call should not create legend in some cases

Submitted by:  sergey plotnikov <nul0m>
Submitted on:  Thu 03 Apr 2014 08:50:15 AM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: GNU/Linux

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)

Wed 07 May 2014 02:58:46 AM UTC, comment #7:

It should be all fixed up in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/adb948d7fae4). Closing report.

Rik <rik5>
Project Administrator
Tue 06 May 2014 05:47:03 PM UTC, comment #6:

yes, it's []. here is the output:

sergey plotnikov <nul0m>
Tue 06 May 2014 04:25:59 PM UTC, comment #5:

@ssergey: Could you run one more test. I want to know how legend behaves when it is called without arguments, but the DisplayName property is set.

Is hleg still [] for this call?

Rik <rik5>
Project Administrator
Sun 13 Apr 2014 04:04:04 PM UTC, comment #4:

Thanks for the extra testing. We now know, at least, what behavior Octave should be trying to mimic. I've marked the bug as confirmed.

Rik <rik5>
Project Administrator
Fri 04 Apr 2014 08:44:23 AM UTC, comment #3:

Sorry, I should have provided more details on how I thought.

  1. My assumption was that legend () is identical to legend (gca), which is not stated explicitly in the documentation, but is quite logical.
  2. It was also logical to me (according to the quote I posted) that the empty legend_handle as an output of legend (...) command may appear only if legend was not created during that call.
  3. Assuming there's a possibility of creating no legend during a call of legend (...) I tried to come up with a proper inputs (instead of dots) which could cause such a behavior.
  4. legend (<labels>) as well as legend ("show") or legend ("toggle") must create some legend for sure (confirmed)
  5. so the list of possible commands (I guessed) was

Being tested in Matlab just last two commands created a legend with default set of labels ("data1", "data2", ...), all the other displayed no legend and returned [].

@Rik:
So, the first case resulted in hl = [] and no legend displayed and the second one created legend with default labels.

sergey plotnikov <nul0m>
Thu 03 Apr 2014 11:11:42 PM UTC, comment #2:

I agree with Mike that it is unclear what legend() is supposed to do in this case. If you read the documentation for legend it says that when no label is supplied it should create a label using the sequence "data1", "data2", ...

Can someone try the following example in Matlab

Octave seems to do the correct thing here in that it builds a legend object with 3 labels (data1, data2, data3), and then returns the handle. However, maybe you are supposed to do

if you want to use default labels on a plot that doesn't have a legend.

Rik <rik5>
Project Administrator
Thu 03 Apr 2014 07:37:55 PM UTC, comment #1:

I agree with your quote from the Matlab documentation, but it doesn't actually say anywhere on that documentation that calling legend with no arguments is allowed or what it should do. If it does say so and I missed it, please point it out because it's not very clear.

The following example is documented and does work in Octave:

Mike Miller <mtmiller>
Project Administrator
Thu 03 Apr 2014 08:50:15 AM UTC, original submission:

The following case should return [] and not create any legend.

According to this, "legend_handle = legend(...) returns the handle to the legend on the current axes, or [] if no legend exists."

I can confirm that in Matlab it holds for any number of output arguments.

sergey plotnikov <nul0m>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by nul0m (Submitted the item)
  •  

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

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 07 May 2014 02:58:46 AM UTCrik5StatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Tue 06 May 2014 04:25:59 PM UTCrik5StatusConfirmed=>In Progress
    Sun 13 Apr 2014 04:04:04 PM UTCrik5StatusNeed Info=>Confirmed
    Thu 03 Apr 2014 07:38:16 PM UTCmtmillerStatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1