Stopping Legend From Overlapping the Graph

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

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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks. Is that some sort of blending edge feature? I just installed
0.98.5.3, but the sample code gives me the error:

TypeError: __init__() got an unexpected keyword argument 'bbox_to_anchor'

···

On Thu, Jun 25, 2009 at 10:20 PM, Jae-Joon Lee<lee.j.joon@...287...> 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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

sorry.
As guillaume has mentioned, you need to install mpl from svn.

Here is some workaround you can try. I guess it would work with 0.98.5.3.
Basically, you create a separate axes for a legend.

ax1 = axes([0.1, 0.2,0.8, 0.7])
p1, = ax1.plot([1,2,3])
p2, = ax1.plot([3,2,1])

ax2 = axes([0.1, 0.1, 0.8, 0.01], frameon=False)
ax2.xaxis.set_visible(False)
ax2.yaxis.set_visible(False)
l = ax2.legend([p1, p2], ["Legend1", "Legend2"], mode="expand", ncol=2,
               borderaxespad=0.)

-JJ

···

On Sat, Jun 27, 2009 at 6:00 PM, Chris Spencer<chrisspen@...287...> wrote:

Thanks. Is that some sort of blending edge feature? I just installed
0.98.5.3, but the sample code gives me the error:

TypeError: __init__() got an unexpected keyword argument 'bbox_to_anchor'

On Thu, Jun 25, 2009 at 10:20 PM, Jae-Joon Lee<lee.j.joon@...287...> 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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Awesome, thanks. That works perfectly.

Chris

···

On Sun, Jun 28, 2009 at 12:16 AM, Jae-Joon Lee<lee.j.joon@...287...> wrote:

sorry.
As guillaume has mentioned, you need to install mpl from svn.

Here is some workaround you can try. I guess it would work with 0.98.5.3.
Basically, you create a separate axes for a legend.

ax1 = axes([0.1, 0.2,0.8, 0.7])
p1, = ax1.plot([1,2,3])
p2, = ax1.plot([3,2,1])

ax2 = axes([0.1, 0.1, 0.8, 0.01], frameon=False)
ax2.xaxis.set_visible(False)
ax2.yaxis.set_visible(False)
l = ax2.legend([p1, p2], ["Legend1", "Legend2"], mode="expand", ncol=2,
              borderaxespad=0.)

-JJ

On Sat, Jun 27, 2009 at 6:00 PM, Chris Spencer<chrisspen@...287...> wrote:

Thanks. Is that some sort of blending edge feature? I just installed
0.98.5.3, but the sample code gives me the error:

TypeError: __init__() got an unexpected keyword argument 'bbox_to_anchor'

On Thu, Jun 25, 2009 at 10:20 PM, Jae-Joon Lee<lee.j.joon@...287...> 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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users