5656class DraggableLegend (DraggableOffsetBox ):
5757 def __init__ (self , legend , use_blit = False , update = "loc" ):
5858 """
59- update : If "loc", update *loc* parameter of
60- legend upon finalizing. If "bbox", update
61- *bbox_to_anchor* parameter.
59+ Parameters
60+ ----------
61+ update : string
62+ If "loc", update *loc* parameter of legend upon finalizing.
63+ If "bbox", update *bbox_to_anchor* parameter.
6264 """
6365 self .legend = legend
6466
@@ -581,8 +583,8 @@ def __init__(self, parent, handles, labels,
581583 del locals_view
582584 # trim handles and labels if illegal label...
583585 for label , handle in zip (labels [:], handles [:]):
584- if (isinstance (label , six .string_types )
585- and label .startswith ('_' )):
586+ if (isinstance (label , six .string_types ) and
587+ label .startswith ('_' )):
586588 warnings .warn ('The handle {!r} has a label of {!r} which '
587589 'cannot be automatically added to the '
588590 'legend.' .format (handle , label ))
@@ -709,7 +711,7 @@ def __init__(self, parent, handles, labels,
709711
710712 def _set_artist_props (self , a ):
711713 """
712- set the boilerplate props for artists added to axes
714+ Set the boilerplate props for artists added to axes.
713715 """
714716 a .set_figure (self .figure )
715717 if self .isaxes :
@@ -731,7 +733,7 @@ def _get_loc(self):
731733 _loc = property (_get_loc , _set_loc )
732734
733735 def _findoffset (self , width , height , xdescent , ydescent , renderer ):
734- "Helper function to locate the legend"
736+ "Helper function to locate the legend. "
735737
736738 if self ._loc == 0 : # "best".
737739 x , y = self ._find_best_position (width , height , renderer )
@@ -749,7 +751,7 @@ def _findoffset(self, width, height, xdescent, ydescent, renderer):
749751
750752 @allow_rasterization
751753 def draw (self , renderer ):
752- "Draw everything that belongs to the legend"
754+ "Draw everything that belongs to the legend. "
753755 if not self .get_visible ():
754756 return
755757
@@ -836,7 +838,7 @@ def update_default_handler_map(cls, handler_map):
836838
837839 def get_legend_handler_map (self ):
838840 """
839- return the handler map.
841+ Return the handler map.
840842 """
841843
842844 default_handler_map = self .get_default_handler_map ()
@@ -851,7 +853,7 @@ def get_legend_handler_map(self):
851853 @staticmethod
852854 def get_legend_handler (legend_handler_map , orig_handle ):
853855 """
854- return a legend handler from *legend_handler_map* that
856+ Return a legend handler from *legend_handler_map* that
855857 corresponds to *orig_handler*.
856858
857859 *legend_handler_map* should be a dictionary object (that is
@@ -861,7 +863,7 @@ def get_legend_handler(legend_handler_map, orig_handle):
861863 *legend_hanler_map* and return the associated value.
862864 Otherwise, it checks for each of the classes in its
863865 method-resolution-order. If no matching key is found, it
864- returns None.
866+ returns `` None`` .
865867 """
866868 if is_hashable (orig_handle ):
867869 try :
@@ -1058,11 +1060,17 @@ def _auto_legend_data(self):
10581060 return [vertices , bboxes , lines , offsets ]
10591061
10601062 def draw_frame (self , b ):
1061- 'b is a boolean. Set draw frame to b'
1063+ '''
1064+ Set draw frame to b.
1065+
1066+ Parameters
1067+ ----------
1068+ b : bool
1069+ '''
10621070 self .set_frame_on (b )
10631071
10641072 def get_children (self ):
1065- 'return a list of child artists'
1073+ 'Return a list of child artists. '
10661074 children = []
10671075 if self ._legend_box :
10681076 children .append (self ._legend_box )
@@ -1071,26 +1079,28 @@ def get_children(self):
10711079 return children
10721080
10731081 def get_frame (self ):
1074- 'return the Rectangle instance used to frame the legend'
1082+ '''
1083+ Return the `~.patches.Rectangle` instances used to frame the legend.
1084+ '''
10751085 return self .legendPatch
10761086
10771087 def get_lines (self ):
1078- 'return a list of lines.Line2D instances in the legend'
1088+ 'Return a list of `~. lines.Line2D` instances in the legend. '
10791089 return [h for h in self .legendHandles if isinstance (h , Line2D )]
10801090
10811091 def get_patches (self ):
1082- 'return a list of patch instances in the legend'
1092+ 'Return a list of `~.patches.Patch` instances in the legend. '
10831093 return silent_list ('Patch' ,
10841094 [h for h in self .legendHandles
10851095 if isinstance (h , Patch )])
10861096
10871097 def get_texts (self ):
1088- 'return a list of text.Text instance in the legend'
1098+ 'Return a list of `~. text.Text` instances in the legend. '
10891099 return silent_list ('Text' , self .texts )
10901100
10911101 def set_title (self , title , prop = None ):
10921102 """
1093- set the legend title. Fontproperties can be optionally set
1103+ Set the legend title. Fontproperties can be optionally set
10941104 with *prop* parameter.
10951105 """
10961106 self ._legend_title_box ._text .set_text (title )
@@ -1107,16 +1117,16 @@ def set_title(self, title, prop=None):
11071117 self .stale = True
11081118
11091119 def get_title (self ):
1110- 'return Text instance for the legend title'
1120+ 'Return `~.text. Text` instance for the legend title. '
11111121 return self ._legend_title_box ._text
11121122
11131123 def get_window_extent (self , * args , ** kwargs ):
1114- 'return a extent of the legend'
1124+ 'Return extent of the legend. '
11151125 return self .legendPatch .get_window_extent (* args , ** kwargs )
11161126
11171127 def get_frame_on (self ):
11181128 """
1119- Get whether the legend box patch is drawn
1129+ Get whether the legend box patch is drawn.
11201130 """
11211131 return self ._drawFrame
11221132
@@ -1131,7 +1141,7 @@ def set_frame_on(self, b):
11311141
11321142 def get_bbox_to_anchor (self ):
11331143 """
1134- return the bbox that the legend will be anchored
1144+ Return the bbox that the legend will be anchored.
11351145 """
11361146 if self ._bbox_to_anchor is None :
11371147 return self .parent .bbox
@@ -1140,12 +1150,16 @@ def get_bbox_to_anchor(self):
11401150
11411151 def set_bbox_to_anchor (self , bbox , transform = None ):
11421152 """
1143- set the bbox that the legend will be anchored.
1153+ Set the bbox that the legend will be anchored.
1154+
1155+ *bbox* can be
1156+
1157+ - A `~.BboxBase` instance
1158+ - A tuple of ``(left, bottom, width, height)`` in the given transform
1159+ (normalized axes coordinate if None)
1160+ - A tuple of ``[left, bottom]`` where the width and height will be
1161+ assumed to be zero.
11441162
1145- *bbox* can be a BboxBase instance, a tuple of [left, bottom,
1146- width, height] in the given transform (normalized axes
1147- coordinate if None), or a tuple of [left, bottom] where the
1148- width and height will be assumed to be zero.
11491163 """
11501164 if bbox is None :
11511165 self ._bbox_to_anchor = None
@@ -1209,7 +1223,7 @@ def _find_best_position(self, width, height, renderer, consider=None):
12091223 """
12101224 Determine the best location to place the legend.
12111225
1212- ` consider` is a list of (x, y) pairs to consider as a potential
1226+ * consider* is a list of `` (x, y)`` pairs to consider as a potential
12131227 lower-left corner of the legend. All are display coords.
12141228 """
12151229 # should always hold because function is only called internally
@@ -1258,7 +1272,7 @@ def draggable(self, state=None, use_blit=False, update="loc"):
12581272 * False : turn draggable off
12591273
12601274 If draggable is on, you can drag the legend on the canvas with
1261- the mouse. The DraggableLegend helper instance is returned if
1275+ the mouse. The `~. DraggableLegend` helper instance is returned if
12621276 draggable is on.
12631277
12641278 The update parameter control which parameter of the legend changes
0 commit comments