diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index 4b4a6976bb48..46c05d36ac4d 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -4356,7 +4356,8 @@ def legend(self, *args, **kwargs): settings. *frameon*: [ True | False ] - if True, draw a frame. Default is True + if True, draw a frame around the legend. + The default is set by the rcParam 'legend.frameon' *fancybox*: [ None | False | True ] if True, draw a frame with a round fancybox. If None, use rc diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index f8a272e9e546..31019e9f5f9c 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -158,7 +158,7 @@ def __init__(self, parent, handles, labels, title = None, # set a title for the legend bbox_to_anchor = None, # bbox that the legend will be anchored. bbox_transform = None, # transform for the bbox - frameon = True, # draw frame + frameon = None, # draw frame handler_map = None, ): """ @@ -177,7 +177,7 @@ def __init__(self, parent, handles, labels, numpoints the number of points in the legend for line scatterpoints the number of points in the legend for scatter plot scatteryoffsets a list of yoffsets for scatter symbols in legend - frameon if True, draw a frame (default is True) + frameon if True, draw a frame around the legend. If None, use rc fancybox if True, draw a frame with a round fancybox. If None, use rc shadow if True, draw a shadow behind legend ncol number of columns @@ -356,6 +356,8 @@ def __init__(self, parent, handles, labels, self._set_artist_props(self.legendPatch) self._drawFrame = frameon + if frameon is None: + self._drawFrame = rcParams["legend.frameon"] # init with null renderer self._init_legend_box(handles, labels) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index a2118b0d4e63..b2ee183ae5f9 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -462,6 +462,7 @@ def __call__(self, s): 'legend.fontsize' : ['large', validate_fontsize], 'legend.markerscale' : [1.0, validate_float], # the relative size of legend markers vs. original 'legend.shadow' : [False, validate_bool], + 'legend.frameon' : [True, validate_bool], # whether or not to draw a frame around legend # the following dimensions are in fraction of the font size diff --git a/matplotlibrc.template b/matplotlibrc.template index 60956ce758db..ff41e2fc0119 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -249,6 +249,7 @@ backend : %(backend)s #legend.handletextsep : 0.02 # the space between the legend line and legend text #legend.axespad : 0.02 # the border between the axes and legend edge #legend.shadow : False +#legend.frameon : True # whether or not to draw a frame around legend ### FIGURE # See http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure