bugGNU Octave - Bugs: bug #57372, [wish] appearance of legend title...

 
 

bug #57372: [wish] appearance of legend title text could be improved

Submitter:  Rik <rik5>
Submitted:  Sat 07 Dec 2019 12:43:32 AM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Feature Request
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 09 Dec 2019 05:03:47 PM UTC, comment #2: 

Re-titling to reflect remaining issue which is that the appearance of title text could be improved.

Right now the text is fairly far from the legend which it is labeling.  Maybe this could be hacked by changing the "position" property of the text object.

Sample code


plot (1:10);
hl = legend ("ABC");
ht = title (hl, "Legend Title");
pos = get (ht, "position");
pos(2) += 5;
set (ht, "position", pos);


There probably also needs to be a listener on the title property which changes the position of the legend because when the title is used it overlaps the main axes.  See attached file leg_title.png.



Rik <rik5>
Group administrator
Sun 08 Dec 2019 07:13:05 PM UTC, comment #1: 

It isn't perfect, but I made a change that allows title() to accept a legend handle as the first argument.  See https://hg.savannah.gnu.org/hgweb/octave/rev/188fb5415ab5.

The visual appearance is only passable.  In the long run it may be required to write a special algorithm, which is a part of legend.m, that handles placing a title on the legend object and then have the title.m function simply call that code.

Rik <rik5>
Group administrator
Sat 07 Dec 2019 12:43:32 AM UTC, original submission:  

When using title() on legend objects the function complains


octave:2> plot (1:10)
octave:3> hl = legend ("abc")
hl = -40.527
octave:4> title (hl, "Legend Title")
error: Invalid call to title.  Correct usage is:

 -- title (STRING)
 -- title (STRING, PROP, VAL, ...)
 -- title (HAX, ...)
 -- H = title (...)


It is simple enough to work around the title() function in Octave by getting the "title" property of the legend object and setting the "string" property on it.  This does label the legend, although the look is different from that of Matlab.

Sample code for that is


plot (1:10);
hl = legend ("abc");
ht = get (hl, "title");
set (ht, "string", "Legend Title")


The visual appearance in Octave and Matlab are attached.

file Octave_legend_title.png
file Matlab_legend_title.png

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 #48028:  leg_title.png added by rik5 (14KiB - image/png)
file #48021:  Octave_legend_title.png added by rik5 (1KiB - image/png)
file #48022:  Matlab_legend_title.png added by rik5 (5KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-12-09 rik5 Attached File- Added leg_title.png, #48028
        Summary[wish] title() should work for legend objects [wish] appearance of legend title text could be improved
    2019-12-07 rik5 Attached File- Added Octave_legend_title.png, #48021
        Attached File- Added Matlab_legend_title.png, #48022

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code