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

Skip to content

Commit 2721def

Browse files
committed
update legend-related document
svn path=/branches/v0_98_5_maint/; revision=6685
1 parent 952d9f5 commit 2721def

7 files changed

Lines changed: 64 additions & 42 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2008-12-19 Update Axes.legend documnetation. /api/api_changes.rst is also
2+
updated to describe chages in keyword parameters.
3+
Issue a warning if old keyword parameters are used. - JJL
14

25
=======================================================================
36
Re-Released 0.98.5.2 at r6679

doc/api/api_changes.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ list may help describe what changes may be necessary in your code.
88

99
Changes for 0.98.x
1010
==================
11+
* Following keyword parameters for :class:`matplotlib.label.Label` are now
12+
deprecated and new set of parameters are introduced. The new parameters
13+
are given as a fraction of the font-size. Also, *scatteryoffsets*,
14+
*fancybox* and *columnspacing* are added as keyword parameters.
15+
16+
================ ================
17+
Deprecated New
18+
================ ================
19+
pad borderpad
20+
labelsep labelspacing
21+
handlelen handlelength
22+
handlestextsep handletextpad
23+
axespad borderaxespad
24+
================ ================
25+
26+
1127
* Removed the configobj and experiemtnal traits rc support
1228

1329
* Modified :func:`matplotlib.mlab.psd`, :func:`matplotlib.mlab.csd`,

lib/matplotlib/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,14 @@ def matplotlib_fname():
582582
'tick.size' : 'tick.major.size',
583583
}
584584

585+
_deprecated_ignore_map = {
586+
'legend.pad' : 'legend.borderpad',
587+
'legend.labelsep' : 'legend.labelspacing',
588+
'legend.handlelen' : 'legend.handlelength',
589+
'legend.handletextsep' : 'legend.handletextpad',
590+
'legend.axespad' : 'legend.borderaxespad',
591+
}
592+
585593

586594
class RcParams(dict):
587595

@@ -602,6 +610,10 @@ def __setitem__(self, key, val):
602610
warnings.warn('%s is deprecated in matplotlibrc. Use %s \
603611
instead.'% (key, alt))
604612
key = alt
613+
elif key in _deprecated_ignore_map:
614+
alt = _deprecated_ignore_map[key]
615+
warnings.warn('%s is deprecated. Use %s instead.'% (key, alt))
616+
return
605617
cval = self.validate[key](val)
606618
dict.__setitem__(self, key, cval)
607619
except KeyError:
@@ -665,6 +677,9 @@ def rc_params(fail_on_error=False):
665677
except Exception, msg:
666678
warnings.warn('Bad val "%s" on line #%d\n\t"%s"\n\tin file \
667679
"%s"\n\t%s' % (val, cnt, line, fname, msg))
680+
elif key in _deprecated_ignore_map:
681+
warnings.warn('%s is deprecated. Update your matplotlibrc to use %s instead.'% (key, _deprecated_ignore_map[key]))
682+
668683
else:
669684
print >> sys.stderr, """
670685
Bad key "%s" on line %d in

lib/matplotlib/axes.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,31 +3728,27 @@ def legend(self, *args, **kwargs):
37283728
A :class:`matplotlib.font_manager.FontProperties`
37293729
instance, or *None* to use rc settings.
37303730
3731-
*pad*: [ None | scalar ]
3732-
The fractional whitespace inside the legend border, between 0 and 1.
3733-
If *None*, use rc settings.
3734-
37353731
*markerscale*: [ None | scalar ]
37363732
The relative size of legend markers vs. original. If *None*, use rc
37373733
settings.
37383734
37393735
*shadow*: [ None | False | True ]
37403736
If *True*, draw a shadow behind legend. If *None*, use rc settings.
37413737
3742-
*labelsep*: [ None | scalar ]
3743-
The vertical space between the legend entries. If *None*, use rc
3744-
settings.
3745-
3746-
*handlelen*: [ None | scalar ]
3747-
The length of the legend lines. If *None*, use rc settings.
3748-
3749-
*handletextsep*: [ None | scalar ]
3750-
The space between the legend line and legend text. If *None*, use rc
3751-
settings.
3752-
3753-
*axespad*: [ None | scalar ]
3754-
The border between the axes and legend edge. If *None*, use rc
3755-
settings.
3738+
Padding and spacing between various elements use following keywords
3739+
parameters. The dimensions of these values are given as a fraction
3740+
of the fontsize. Values from rcParams will be used if None.
3741+
3742+
================ ==================================================================
3743+
Keyword Description
3744+
================ ==================================================================
3745+
borderpad the fractional whitespace inside the legend border
3746+
labelspacing the vertical space between the legend entries
3747+
handlelength the length of the legend handles
3748+
handletextpad the pad between the legend handle and text
3749+
borderaxespad the pad between the axes and legend border
3750+
columnspacing the spacing between columns
3751+
================ ==================================================================
37563752
37573753
**Example:**
37583754

lib/matplotlib/legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(self, parent, handles, labels,
9898
handletextsep = None, # deprecated; use handletextpad
9999
axespad = None, # deprecated; use borderaxespad
100100

101-
# spacing & pad defined as a fractionof the font-size
101+
# spacing & pad defined as a fraction of the font-size
102102
borderpad = None, # the whitespace inside the legend border
103103
labelspacing=None, #the vertical space between the legend entries
104104
handlelength=None, # the length of the legend handles

lib/matplotlib/mpl-data/matplotlib.conf.template

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,11 @@ units = False
233233
origin = 'upper'
234234

235235
[legend]
236-
# a float
237-
axespad = 0.02
238236
# a float or 'xx-small' or 'x-small' or 'small' or 'medium' or 'large' or
239237
# 'x-large' or 'xx-large'
240238
fontsize = 'medium'
241-
# a float
242-
handlelen = 0.050000000000000003
243-
# a float
244-
handletextsep = 0.02
245239
# a boolean
246240
isaxes = True
247-
# a float
248-
labelsep = 0.01
249241
# 'best' or 'upper right' or 'upper left' or 'lower left' or 'lower right'
250242
# or 'right' or 'center left' or 'center right' or 'lower center' or
251243
# 'upper center' or 'center'
@@ -254,10 +246,21 @@ units = False
254246
markerscale = 1.0
255247
# an integer
256248
numpoints = 3
257-
# a float
258-
pad = 0.20000000000000001
259249
# a boolean
260250
shadow = False
251+
# float
252+
borderpad = 0.4
253+
# float
254+
labelspacing = 0.5
255+
# float
256+
handlelength = 2.
257+
# float
258+
handletextpad = 0.8
259+
# float
260+
borderaxespad = 0.5
261+
# float
262+
columnspacing = 2.
263+
261264

262265
[lines]
263266
# a boolean

lib/matplotlib/rcsetup.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -422,18 +422,12 @@ def __call__(self, s):
422422
'legend.isaxes' : [True,validate_bool], # this option is internally ignored - it never served any useful purpose
423423
'legend.numpoints' : [2, validate_int], # the number of points in the legend line
424424
'legend.fontsize' : ['large', validate_fontsize],
425-
'legend.pad' : [0, validate_float], # was 0.2, deprecated; the fractional whitespace inside the legend border
426-
'legend.borderpad' : [0.4, validate_float], # units are fontsize
427425
'legend.markerscale' : [1.0, validate_float], # the relative size of legend markers vs. original
428-
429-
# the following dimensions are in axes coords
430-
'legend.labelsep' : [0.010, validate_float], # the vertical space between the legend entries
431-
'legend.handlelen' : [0.05, validate_float], # the length of the legend lines
432-
'legend.handletextsep' : [0.02, validate_float], # the space between the legend line and legend text
433-
'legend.axespad' : [0.02, validate_float], # the border between the axes and legend edge
434426
'legend.shadow' : [False, validate_bool],
435427

436428

429+
# the following dimensions are in fraction of the font size
430+
'legend.borderpad' : [0.4, validate_float], # units are fontsize
437431
'legend.labelspacing' : [0.5, validate_float], # the vertical space between the legend entries
438432
'legend.handlelength' : [2., validate_float], # the length of the legend lines
439433
'legend.handletextpad' : [.8, validate_float], # the space between the legend line and legend text
@@ -443,11 +437,6 @@ def __call__(self, s):
443437

444438
'legend.markerscale' : [1.0, validate_float], # the relative size of legend markers vs. original
445439

446-
# the following dimensions are in axes coords
447-
'legend.labelsep' : [0.010, validate_float], # the vertical space between the legend entries
448-
'legend.handlelen' : [0.05, validate_float], # the length of the legend lines
449-
'legend.handletextsep' : [0.02, validate_float], # the space between the legend line and legend text
450-
'legend.axespad' : [0.5, validate_float], # the border between the axes and legend edge
451440
'legend.shadow' : [False, validate_bool],
452441

453442

0 commit comments

Comments
 (0)