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

Skip to content

Commit fa34344

Browse files
committed
Merge pull request #145 from kaufman/legend_rcparams_frameon2
2 parents 649df91 + b197d80 commit fa34344

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

lib/matplotlib/axes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4356,7 +4356,8 @@ def legend(self, *args, **kwargs):
43564356
settings.
43574357
43584358
*frameon*: [ True | False ]
4359-
if True, draw a frame. Default is True
4359+
if True, draw a frame around the legend.
4360+
The default is set by the rcParam 'legend.frameon'
43604361
43614362
*fancybox*: [ None | False | True ]
43624363
if True, draw a frame with a round fancybox. If None, use rc

lib/matplotlib/legend.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def __init__(self, parent, handles, labels,
158158
title = None, # set a title for the legend
159159
bbox_to_anchor = None, # bbox that the legend will be anchored.
160160
bbox_transform = None, # transform for the bbox
161-
frameon = True, # draw frame
161+
frameon = None, # draw frame
162162
handler_map = None,
163163
):
164164
"""
@@ -177,7 +177,7 @@ def __init__(self, parent, handles, labels,
177177
numpoints the number of points in the legend for line
178178
scatterpoints the number of points in the legend for scatter plot
179179
scatteryoffsets a list of yoffsets for scatter symbols in legend
180-
frameon if True, draw a frame (default is True)
180+
frameon if True, draw a frame around the legend. If None, use rc
181181
fancybox if True, draw a frame with a round fancybox. If None, use rc
182182
shadow if True, draw a shadow behind legend
183183
ncol number of columns
@@ -356,6 +356,8 @@ def __init__(self, parent, handles, labels,
356356
self._set_artist_props(self.legendPatch)
357357

358358
self._drawFrame = frameon
359+
if frameon is None:
360+
self._drawFrame = rcParams["legend.frameon"]
359361

360362
# init with null renderer
361363
self._init_legend_box(handles, labels)

lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ def __call__(self, s):
462462
'legend.fontsize' : ['large', validate_fontsize],
463463
'legend.markerscale' : [1.0, validate_float], # the relative size of legend markers vs. original
464464
'legend.shadow' : [False, validate_bool],
465+
'legend.frameon' : [True, validate_bool], # whether or not to draw a frame around legend
465466

466467

467468
# the following dimensions are in fraction of the font size

matplotlibrc.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ backend : %(backend)s
249249
#legend.handletextsep : 0.02 # the space between the legend line and legend text
250250
#legend.axespad : 0.02 # the border between the axes and legend edge
251251
#legend.shadow : False
252+
#legend.frameon : True # whether or not to draw a frame around legend
252253

253254
### FIGURE
254255
# See http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure

0 commit comments

Comments
 (0)