legend border, frameon keyword

I want a legend without the black border. I've tried a few things that have
been suggested on this forum and elsewhere to no avail. According to what
I've seen, it should be as simple as:

import matplotlib.pyplot as plt
import numpy as np

N = 5
Means1 = (20, 35, 30, 35, 27)
Means2 = (25, 32, 34, 20, 25)

ind = np.arange(N) # the x locations for the groups
width = 0.20 # the width of the bars

fig = plt.figure()
ax = fig.add_subplot(111)
rects1 = ax.bar(ind, Means1, width, color='k')
rects2 = ax.bar(ind+width, Means2, width, color='w')

ax.legend( (rects1[0], rects2[0]), ('set1', 'set2'), frameon=False )

plt.show()

It all works except for "frameon=False"

I get this:

/usr/lib/pymodules/python2.7/matplotlib/axes.pyc in legend(self, *args,
**kwargs)
   4042
   4043 handles = cbook.flatten(handles)
-> 4044 self.legend_ = mlegend.Legend(self, handles, labels,
**kwargs)
   4045 return self.legend_
   4046

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

I've also checked my matplotlibrc under the "Legend" section and I don't see
a "legend.frameon" line.

It must be something simple that I am doing wrong. Any ideas?

···

--
View this message in context: http://old.nabble.com/legend-border%2C-frameon-keyword-tp32807933p32807933.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Hi,

I usually do like this

l = ax.legend( (rects1[0], rects2[0]), ('set1', 'set2'))
l.draw_frame(False)

Cheers,

Francesco

2011/11/9 magurling <magurling@...287...>:

···

I want a legend without the black border. I've tried a few things that have
been suggested on this forum and elsewhere to no avail. According to what
I've seen, it should be as simple as:

import matplotlib.pyplot as plt
import numpy as np

N = 5
Means1 = (20, 35, 30, 35, 27)
Means2 = (25, 32, 34, 20, 25)

ind = np.arange(N) # the x locations for the groups
width = 0.20 # the width of the bars

fig = plt.figure()
ax = fig.add_subplot(111)
rects1 = ax.bar(ind, Means1, width, color='k')
rects2 = ax.bar(ind+width, Means2, width, color='w')

ax.legend( (rects1[0], rects2[0]), ('set1', 'set2'), frameon=False )

plt.show()

It all works except for "frameon=False"

I get this:

/usr/lib/pymodules/python2.7/matplotlib/axes.pyc in legend(self, *args,
**kwargs)
4042
4043 handles = cbook.flatten(handles)
-> 4044 self.legend_ = mlegend.Legend(self, handles, labels,
**kwargs)
4045 return self.legend_
4046

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

I've also checked my matplotlibrc under the "Legend" section and I don't see
a "legend.frameon" line.

It must be something simple that I am doing wrong. Any ideas?
--
View this message in context: http://old.nabble.com/legend-border%2C-frameon-keyword-tp32807933p32807933.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks Francesco, but I've also tried to use the "draw_frame(False)" method
with no luck.

montefra wrote:

···

Hi,

I usually do like this

l = ax.legend( (rects1[0], rects2[0]), ('set1', 'set2'))
l.draw_frame(False)

Cheers,

Francesco

2011/11/9 magurling <magurling@...287...>:

I want a legend without the black border. I've tried a few things that
have
been suggested on this forum and elsewhere to no avail. According to what
I've seen, it should be as simple as:

import matplotlib.pyplot as plt
import numpy as np

N = 5
Means1 = (20, 35, 30, 35, 27)
Means2 = (25, 32, 34, 20, 25)

ind = np.arange(N) # the x locations for the groups
width = 0.20 # the width of the bars

fig = plt.figure()
ax = fig.add_subplot(111)
rects1 = ax.bar(ind, Means1, width, color='k')
rects2 = ax.bar(ind+width, Means2, width, color='w')

ax.legend( (rects1[0], rects2[0]), ('set1', 'set2'), frameon=False )

plt.show()

It all works except for "frameon=False"

I get this:

/usr/lib/pymodules/python2.7/matplotlib/axes.pyc in legend(self, *args,
**kwargs)
4042
4043 handles = cbook.flatten(handles)
-> 4044 self.legend_ = mlegend.Legend(self, handles, labels,
**kwargs)
4045 return self.legend_
4046

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

I've also checked my matplotlibrc under the "Legend" section and I don't
see
a "legend.frameon" line.

It must be something simple that I am doing wrong. Any ideas?
--
View this message in context:
http://old.nabble.com/legend-border%2C-frameon-keyword-tp32807933p32807933.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/legend-border%2C-frameon-keyword-tp32807933p32827812.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I updated matplotlib to 1.1.0; both methods work now. I would say "Thanks
Paul and Francesco" but I just read the mailing list etiquette.

···

--
View this message in context: http://old.nabble.com/legend-border%2C-frameon-keyword-tp32807933p32828355.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I updated matplotlib to 1.1.0; both methods work now.

Thanks for letting us know, and glad it works for you now - that
information is useful for those who search for similar error messages
in the future and find this thread.

I would say "Thanks Paul and Francesco" but I just read the mailing list etiquette.

you're very welcome - though I'm not sure what etiquette you're
referring to? I think it's useful for poster who ask for help to
report back when they've overcome whatever problem they were having
along with how they resolved it, so that others can follow in their
footsteps later.

best,

···

On Fri, Nov 11, 2011 at 12:40 PM, magurling <magurling@...287...> wrote:
--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7