2525from numerix import array , ones , Float
2626
2727
28- from matplotlib import verbose
28+ from matplotlib import verbose , rcParams
2929from artist import Artist
3030from cbook import enumerate , is_string_like , iterable , silent_list
3131from font_manager import FontProperties
@@ -110,18 +110,18 @@ class Legend(Artist):
110110
111111
112112 def __init__ (self , parent , handles , labels , loc ,
113- isaxes = True ,
114- numpoints = 4 , # the number of points in the legend line
115- prop = FontProperties ( size = 'smaller' ) ,
116- pad = 0.2 , # the fractional whitespace inside the legend border
117- markerscale = 0.6 , # the relative size of legend markers vs. original
113+ isaxes = None ,
114+ numpoints = None , # the number of points in the legend line
115+ prop = None ,
116+ pad = None , # the fractional whitespace inside the legend border
117+ markerscale = None , # the relative size of legend markers vs. original
118118 # the following dimensions are in axes coords
119- labelsep = 0.005 , # the vertical space between the legend entries
120- handlelen = 0.05 , # the length of the legend lines
121- handletextsep = 0.02 , # the space between the legend line and legend text
122- axespad = 0.02 , # the border between the axes and legend edge
119+ labelsep = None , # the vertical space between the legend entries
120+ handlelen = None , # the length of the legend lines
121+ handletextsep = None , # the space between the legend line and legend text
122+ axespad = None , # the border between the axes and legend edge
123123
124- shadow = False ,
124+ shadow = None ,
125125 ):
126126 """
127127 parent # the artist that contains the legend
@@ -146,19 +146,19 @@ def __init__(self, parent, handles, labels, loc,
146146 warnings .warn ('Unrecognized location %s. Falling back on upper right; valid locations are\n %s\t ' % (loc , '\n \t ' .join (self .codes .keys ())))
147147 if is_string_like (loc ): loc = self .codes .get (loc , 1 )
148148
149- self . numpoints = numpoints
150- self . prop = prop
151- self . fontsize = prop . get_size_in_points ()
152- self . pad = pad
153- self . markerscale = markerscale
154- self . labelsep = labelsep
155- self . handlelen = handlelen
156- self .handletextsep = handletextsep
157- self . axespad = axespad
158- self .shadow = shadow
159-
160- self . isaxes = isaxes
161- if isaxes : # parent is an Axes
149+ proplist = [ numpoints , pad , markerscale , labelsep , handlelen , handletextsep , axespad , shadow , isaxes ]
150+ propnames = [ 'numpoints' , 'pad' , 'markerscale' , 'labelsep' , 'handlelen' , 'handletextsep' , 'axespad' , 'shadow' , 'isaxes' ]
151+ for name , value in zip ( propnames , proplist ):
152+ if value is None :
153+ value = rcParams [ "legend." + name ]
154+ setattr ( self , name , value )
155+ if prop is None :
156+ self .prop = FontProperties ( size = rcParams [ "legend.fontsize" ])
157+ else :
158+ self .prop = prop
159+ self . fontsize = self . prop . get_size_in_points ()
160+
161+ if self . isaxes : # parent is an Axes
162162 self .set_figure (parent .figure )
163163 else : # parent is a Figure
164164 self .set_figure (parent )
0 commit comments