Right align legend contents

Hi,

Is it possible to right align the text and line samples in a legend box?

That is, instead of:

--- First plot
--- Second plot

...you get:

  First plot ---
Second plot ---

(with a fixed width font, that last one displays the right edges of
the text perfectly aligned).

Cheers,
Jason

plot([1,2,3], label="Label 1")
plot([2,1,3], label="Long Label 2")

leg = legend()

# swap_and_right_align_legend

vp = leg._legend_box._children[-1]._children[0]
for c in vp._children:
    c._children.reverse()
vp.align="right"

draw()

Does this close to waht you want?

-JJ

···

On Wed, Dec 9, 2009 at 12:28 AM, Jason Heeris <jason.heeris@...287...> wrote:

Hi,

Is it possible to right align the text and line samples in a legend box?

That is, instead of:

--- First plot
--- Second plot

...you get:

First plot ---
Second plot ---

(with a fixed width font, that last one displays the right edges of
the text perfectly aligned).

Cheers,
Jason

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

2009/12/9 Jae-Joon Lee <lee.j.joon@...287...>:

vp = leg._legend_box._children[-1]._children[0]
for c in vp._children:
   c._children.reverse()
vp.align="right"

That's perfect, thank you very much :slight_smile:

— Jason