From 01c2de00ea2add9a6b3902e10dbc67d0f814943e Mon Sep 17 00:00:00 2001 From: Mike Kaufman Date: Sat, 9 Apr 2011 18:30:13 -0400 Subject: [PATCH 1/3] add "legend.frameon" to rcParams modified: lib/matplotlib/axes.py modified: lib/matplotlib/legend.py modified: lib/matplotlib/rcsetup.py modified: matplotlibrc.template --- lib/matplotlib/axes.py | 2 +- lib/matplotlib/legend.py | 7 ++++--- lib/matplotlib/rcsetup.py | 1 + matplotlibrc.template | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index 4b4a6976bb48..2e535f0e6ba8 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -4356,7 +4356,7 @@ 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. *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..b01a7ebead76 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 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 @@ -355,7 +355,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 From 6203e80d307a7a535ac6381e150882cf2d0742dd Mon Sep 17 00:00:00 2001 From: Mike Kaufman Date: Sun, 17 Apr 2011 10:52:06 -0700 Subject: [PATCH 2/3] add additional helptext that elaborates on the default option (rc) modified: axes.py modified: legend.py --- lib/matplotlib/axes.py | 1 + lib/matplotlib/legend.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index 2e535f0e6ba8..46c05d36ac4d 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -4357,6 +4357,7 @@ def legend(self, *args, **kwargs): *frameon*: [ True | False ] 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 b01a7ebead76..205eff85c526 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -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 around the legend + 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 From b197d8016029516f1f8c58b2b3cdc4d1005fd987 Mon Sep 17 00:00:00 2001 From: Mike Kaufman Date: Sun, 15 May 2011 13:26:38 -0400 Subject: [PATCH 3/3] handle case where frameon kwarg is not None modified: legend.py --- lib/matplotlib/legend.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index 205eff85c526..31019e9f5f9c 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -355,6 +355,7 @@ def __init__(self, parent, handles, labels, self._set_artist_props(self.legendPatch) + self._drawFrame = frameon if frameon is None: self._drawFrame = rcParams["legend.frameon"]