Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eab892e

Browse files
committed
add framon option for legend
svn path=/trunk/matplotlib/; revision=7841
1 parent c03d2b1 commit eab892e

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3925,6 +3925,9 @@ def legend(self, *args, **kwargs):
39253925
The relative size of legend markers vs. original. If *None*, use rc
39263926
settings.
39273927
3928+
*frameon*: [ True | False ]
3929+
if True, draw a frame. Default is True
3930+
39283931
*fancybox*: [ None | False | True ]
39293932
if True, draw a frame with a round fancybox. If None, use rc
39303933

lib/matplotlib/legend.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def __init__(self, parent, handles, labels,
115115
title = None, # set a title for the legend
116116
bbox_to_anchor = None, # bbox that the legend will be anchored.
117117
bbox_transform = None, # transform for the bbox
118+
frameon = True, # draw frame
118119
):
119120
"""
120121
- *parent* : the artist that contains the legend
@@ -132,6 +133,7 @@ def __init__(self, parent, handles, labels,
132133
numpoints the number of points in the legend for line
133134
scatterpoints the number of points in the legend for scatter plot
134135
scatteryoffsets a list of yoffsets for scatter symbols in legend
136+
frameon if True, draw a frame (default is True)
135137
fancybox if True, draw a frame with a round fancybox. If None, use rc
136138
shadow if True, draw a shadow behind legend
137139
ncol number of columns
@@ -303,7 +305,7 @@ def __init__(self, parent, handles, labels,
303305

304306
self._set_artist_props(self.legendPatch)
305307

306-
self._drawFrame = True
308+
self._drawFrame = frameon
307309

308310
# init with null renderer
309311
self._init_legend_box(handles, labels)
@@ -687,7 +689,7 @@ def _auto_legend_data(self):
687689

688690
def draw_frame(self, b):
689691
'b is a boolean. Set draw frame to b'
690-
self._drawFrame = b
692+
self.set_frame_on(b)
691693

692694
def get_children(self):
693695
'return a list of child artists'
@@ -737,6 +739,20 @@ def get_window_extent(self):
737739
return self.legendPatch.get_window_extent()
738740

739741

742+
def get_frame_on(self):
743+
"""
744+
Get whether the legend box patch is drawn
745+
"""
746+
return self._drawFrame
747+
748+
def set_frame_on(self, b):
749+
"""
750+
Set whether the legend box patch is drawn
751+
752+
ACCEPTS: [ *True* | *False* ]
753+
"""
754+
self._drawFrame = b
755+
740756
def get_bbox_to_anchor(self):
741757
"""
742758
return the bbox that the legend will be anchored

0 commit comments

Comments
 (0)