bugGNU Octave - Bugs: bug #56528, HorizontalAlignment in legend not...


bug #56528: HorizontalAlignment in legend not working

Submitted by:  Muhali <muhali>
Submitted on:  Thu 20 Jun 2019 04:38:54 PM UTC  
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Invalid Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  5.1.0 Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

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


Sat 22 Jun 2019 05:16:57 PM UTC, comment #4: 

@Muhali: There is no easy way to control the text positioning out of the "textposition" property. Actually the text is left aligned and the anchor is at the right hand tip of the line plus a small hard-coded margin, hence the observed behavior when you switch the alignement to "right".

I'm inclined to close this report as "invalid" since there is no actual bug, unless you want to turn it into a feature request. Don't expect much though, fixing the dozen of true legend bugs we  have at hand should be a priority.

Pantxo Diribarne <pantxo>
Project Member
Fri 21 Jun 2019 08:07:31 AM UTC, comment #3: 

@pantxo: No, set (hl, "textposition", "left") is not what I had in mind.

If the lines are e.g. on the left side, I am looking for a way to align the text either right, ending at the right legend boundary, or left, starting at the lines. Currently the text seems to be centered.

Muhali <muhali>
Thu 20 Jun 2019 09:09:51 PM UTC, comment #2: 

@Mukali: What are you trying to do in the first place? I think text/line/patch objects in legend-axes are considered "internals". The interface to manipulate the aspect of legends is limited to top level legend axes properties, e.g.

plot (1:10)
hl = legend ("toto");
set (hl, "textposition", "left")

I don't think this is a bug but rather that legend specific properties ("location", "textposition", "fontsize", ...) are poorly documented.

I also think that we should hide internal objects in some way (at least "handlevisibity" = "off"), as Matlab did when legend axes became proper legend objects (see empty children in  https://www.mathworks.com/help/matlab/ref/matlab.graphics.illustration.legend-properties.html).

Pantxo Diribarne <pantxo>
Project Member
Thu 20 Jun 2019 06:05:08 PM UTC, comment #1: 

Confirm with dev version.


Dmitri A. Sergatskov <dasergatskov>
Thu 20 Jun 2019 04:38:54 PM UTC, original submission:  

by doing

plot(rand(3,2)) ;
h = legend({"l1" "line 2"}) ;
ht = findobj(h, 'type', 'text') ;
set(ht,'HorizontalAlignment', 'right') ;

with qt, the legend text gets mangled with the lines,
with gnuplot, nothing happens.

Muhali <muhali>


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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


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

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

    Only project members can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-07-11 rik5 Open/ClosedOpen => Closed
    2019-06-22 pantxo StatusNone => Invalid
        Operating SystemGNU/Linux => Any

    Back to the top

    Powered by Savane 3.5