From: <ef...@us...> - 2008-10-05 01:38:42
|
Revision: 6147 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6147&view=rev Author: efiring Date: 2008-10-05 01:38:31 +0000 (Sun, 05 Oct 2008) Log Message: ----------- New legend kwarg: borderpad to replace pad (primary code by Jae-Joon Lee) Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/legend.py trunk/matplotlib/lib/matplotlib/rcsetup.py trunk/matplotlib/matplotlibrc.template Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-10-04 13:09:52 UTC (rev 6146) +++ trunk/matplotlib/CHANGELOG 2008-10-05 01:38:31 UTC (rev 6147) @@ -1,3 +1,6 @@ +2008-10-04 Experimental new kwarg borderpad to replace pad in legend, + based on suggestion by Jae-Joon Lee. - EF + 2008-09-27 Allow spy to ignore zero values in sparse arrays, based on patch by Tony Yu. Also fixed plot to handle empty data arrays, and fixed handling of markers in figlegend. - EF Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2008-10-04 13:09:52 UTC (rev 6146) +++ trunk/matplotlib/lib/matplotlib/legend.py 2008-10-05 01:38:31 UTC (rev 6147) @@ -85,6 +85,7 @@ numpoints = None, # the number of points in the legend line prop = None, pad = None, # the fractional whitespace inside the legend border + borderpad = None, markerscale = None, # the relative size of legend markers vs. original # the following dimensions are in axes coords labelsep = None, # the vertical space between the legend entries @@ -116,12 +117,15 @@ Artist.__init__(self) - proplist=[numpoints, pad, markerscale, labelsep, handlelen, handletextsep, axespad, shadow] - propnames=['numpoints', 'pad', 'markerscale', 'labelsep', 'handlelen', 'handletextsep', 'axespad', 'shadow'] + proplist=[numpoints, pad, borderpad, markerscale, labelsep, handlelen, handletextsep, axespad, shadow] + propnames=['numpoints', 'pad', 'borderpad', 'markerscale', 'labelsep', 'handlelen', 'handletextsep', 'axespad', 'shadow'] for name, value in safezip(propnames,proplist): if value is None: value=rcParams["legend."+name] setattr(self,name,value) + if pad: + warnings.DeprecationWarning("Use 'borderpad' instead of 'pad'.") + # 2008/10/04 if self.numpoints <= 0: raise ValueError("numpoints must be >= 0; it was %d"% numpoints) if prop is None: @@ -532,8 +536,14 @@ # Set the data for the legend patch bbox = self._get_handle_text_bbox(renderer) - bbox = bbox.expanded(1 + self.pad, 1 + self.pad) + if self.pad: + bbox = bbox.expanded(1 + self.pad, 1 + self.pad) + else: + bbox = bbox.transformed(self.get_transform()) + bbox = bbox.padded(self.borderpad*self.fontsize) + bbox = bbox.inverse_transformed(self.get_transform()) l, b, w, h = bbox.bounds + self.legendPatch.set_bounds(l, b, w, h) ox, oy = 0, 0 # center Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-10-04 13:09:52 UTC (rev 6146) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-10-05 01:38:31 UTC (rev 6147) @@ -416,7 +416,8 @@ 'legend.isaxes' : [True,validate_bool], # this option is internally ignored - it never served any useful purpose 'legend.numpoints' : [2, validate_int], # the number of points in the legend line 'legend.fontsize' : ['large', validate_fontsize], - 'legend.pad' : [0.2, validate_float], # the fractional whitespace inside the legend border + 'legend.pad' : [0, validate_float], # was 0.2, deprecated; the fractional whitespace inside the legend border + 'legend.borderpad' : [0.5, validate_float], # units are fontsize 'legend.markerscale' : [1.0, validate_float], # the relative size of legend markers vs. original # the following dimensions are in axes coords Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2008-10-04 13:09:52 UTC (rev 6146) +++ trunk/matplotlib/matplotlibrc.template 2008-10-05 01:38:31 UTC (rev 6147) @@ -233,7 +233,8 @@ #legend.isaxes : True #legend.numpoints : 2 # the number of points in the legend line #legend.fontsize : large -#legend.pad : 0.2 # the fractional whitespace inside the legend border +#legend.pad : 0.0 # deprecated; the fractional whitespace inside the legend border +#legend.borderpad : 0.5 # border whitspace in fontsize units #legend.markerscale : 1.0 # the relative size of legend markers vs. original # the following dimensions are in axes coords #legend.labelsep : 0.010 # the vertical space between the legend entries This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |