bugGNU Octave - Bugs: bug #57271, problems with legend() when labels...

 
 

bug #57271: problems with legend() when labels are empty or spaces only

Submitter:  Rik <rik5>
Submitted:  Tue 19 Nov 2019 06:04:40 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 23 Nov 2019 06:12:22 PM UTC, comment #4: 

Working as expected now.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Sat 23 Nov 2019 12:26:13 PM UTC, comment #3: 

I pusged the following change:

http://hg.savannah.gnu.org/hgweb/octave/rev/7fff532afcb1

This also fixes other bugs with the displayname handling.

Pantxo Diribarne <pantxo>
Group Member
Tue 19 Nov 2019 07:08:03 PM UTC, comment #2: 

It fixes it for the first case, but now new labels are not updated if legend is called again.


x = 1:10;
plot (x,x, x, x+2)
legend ('', 'x + 2')
hl = legend
legend ('a', 'b')



Rik <rik5>
Group administrator
Tue 19 Nov 2019 06:38:15 PM UTC, comment #1: 

I think the attached patch fixes the first issue.

(file #47901)

Pantxo Diribarne <pantxo>
Group Member
Tue 19 Nov 2019 06:04:40 PM UTC, original submission:  

Problem #1: empty label replaced by "data1"

Code to reproduce:


x = 1:10;
plot (x,x, x, x+2)
legend ('', 'x + 2')
hl = legend


The first call to legend correctly places blank text next to the legend key for the first line.  However, when legend is called a second time the blank label is replaced by the text 'data1'.

My guess is that the legend code which checks whether DisplayName is empty should also check whether it is a string or numeric.  If the default DisplayName was '[]' then it would be possible to distinguish between labels which have never been set and '""' labels which are empty strings and were intentionally set by the programmer.

Problem #2: Using spaces as labels causes legend keys to be misaligned.

Code to reproduce.


x = 1:10;
plot (x,x, x, x+2)
legend (' ', 'x + 2')


The first line is offset to the right with respect to the second one.  This effect is only visible on screen.  Printing the figure results in the correct placement.

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 #47901:  bug57271.patch added by pantxo (3KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Updated the item)
  • -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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-11-23 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-11-23 pantxo StatusIn Progress Ready For Test
    2019-11-19 rik5 StatusConfirmed In Progress
    2019-11-19 pantxo Attached File- Added bug57271.patch, #47901
    2019-11-19 rik5 Carbon-Copy- Added pantxo

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code