Stopping Legend From Overlapping the Graph

I forgot to CC the list :S

and I updated to svn trunk and it now works fine :slight_smile:

guillaume ranquet wrote:

路路路

this question raised my interest and I tried It.
unfortunately, I get errors :frowning:

when executing the demo source code linked, I get

$ python ~/testmpl.py
Traceback (most recent call last):
  File "/home/granquet/testmpl.py", line 7, in <module>
    ncol=2, mode="expand", borderaxespad=0.)
  File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line
2447, in legend
    ret = gca().legend(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 3823,
in legend
    self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'bbox_to_anchor'

I tried with a .set_bbox_to_anchor() but I get:
AttributeError: 'Legend' object has no attribute 'set_bbox_to_anchor'

using matplotlib 0.98.5.3 on linux/gentoo
am I missing something? or is my version of matplotlib not appropriate?

Jae-Joon Lee wrote:

The linked page below shows how you put the legend above the graph.

http://matplotlib.sourceforge.net/users/plotting/legend.html#legend-location

You can put it below the axes by adjusting the bbox_to_anchor parameter.
Try something like
  bbox_to_anchor=(0., -0.1, 1., -0.1), loc=1

Make sure to adjust the suplot parameter (or axes location) to make
enough room for the legend.

-JJ

On Thu, Jun 25, 2009 at 9:22 PM, Chris Spencer<chrisspen@...287...> wrote:

How do you show the legend below the graph, so it doesn't overlap at
all with the graph? The docs for the legend() "loc" parameter only
seem to specify where *on* the graph you want it to show, which is
driving me nuts because even using "best", it usually hides some of my
data.

I want to see *all* of my graph, as well as the legend. Is there any
way to do this with pylab?

Any help is appreciated.

Chris

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

----
This message contains confidential information and may contain information that is legally privileged. If you have received this message by mistake, please immediately notify us and delete the original message. Thank you.

Ce message contient des informations confidentielles. S'il vous est parvenu par erreur, merci de bien vouloir nous en aviser par retour, de n'en faire aucun usage et de n'en garder aucune copie.
----