@@ -438,7 +438,7 @@ def figlegend(handles, labels, loc, **kwargs):
438438 .. seealso::
439439
440440 :func:`~matplotlib.pyplot.legend`
441- For information about the location codes
441+
442442 """
443443 l = gcf ().legend (handles , labels , loc , ** kwargs )
444444 draw_if_interactive ()
@@ -6322,31 +6322,69 @@ def legend(*args, **kwargs):
63226322 'center' 10
63236323 =============== =============
63246324
6325- If none of these are locations are suitable, loc can be a 2-tuple
6326- giving x,y in axes coords, ie::
63276325
6328- loc = 0, 1 # left top
6329- loc = 0.5, 0.5 # center
6326+ Users can specify any arbitrary location for the legend using the
6327+ *bbox_to_anchor* keyword argument. bbox_to_anchor can be an instance
6328+ of BboxBase(or its derivatives) or a tuple of 2 or 4 floats.
6329+ For example, ::
6330+
6331+ loc = 'upper right', bbox_to_anchor = (0.5, 0.5)
6332+
6333+ will place the legend so that the upper right corner of the legend at
6334+ the center of the axes.
6335+
6336+ The legend location can be specified in other coordinate, by using the
6337+ *bbox_transform* keyword.
6338+
6339+ The loc itslef can be a 2-tuple giving x,y of the lower-left corner of
6340+ the legend in axes coords (*bbox_to_anchor* is ignored).
6341+
63306342
63316343Keyword arguments:
63326344
63336345 *isaxes*: [ True | False ]
63346346 Indicates that this is an axes legend
63356347
6348+ *prop*: [ None | FontProperties | dict ]
6349+ A :class:`matplotlib.font_manager.FontProperties`
6350+ instance. If *prop* is a dictionary, a new instance will be
6351+ created with *prop*. If *None*, use rc settings.
6352+
63366353 *numpoints*: integer
6337- The number of points in the legend line, default is 4
6354+ The number of points in the legend for line
63386355
6339- *prop*: [ None | FontProperties ]
6340- A :class:`matplotlib.font_manager.FontProperties`
6341- instance, or *None* to use rc settings.
6356+ *scatterpoints*: integer
6357+ The number of points in the legend for scatter plot
6358+
6359+ *scatteroffsets*: list of floats
6360+ a list of yoffsets for scatter symbols in legend
63426361
63436362 *markerscale*: [ None | scalar ]
63446363 The relative size of legend markers vs. original. If *None*, use rc
63456364 settings.
63466365
6366+ *fancybox*: [ None | False | True ]
6367+ if True, draw a frame with a round fancybox. If None, use rc
6368+
63476369 *shadow*: [ None | False | True ]
63486370 If *True*, draw a shadow behind legend. If *None*, use rc settings.
63496371
6372+ *ncol* : integer
6373+ number of columns. default is 1
6374+
6375+ *mode* : [ "expand" | None ]
6376+ if mode is "expand", the legend will be horizontally expanded
6377+ to fill the axes area (or *bbox_to_anchor*)
6378+
6379+ *bbox_to_anchor* : an instance of BboxBase or a tuple of 2 or 4 floats
6380+ the bbox that the legend will be anchored.
6381+
6382+ *bbox_transform* : [ an instance of Transform | None ]
6383+ the transform for the bbox. transAxes if None.
6384+
6385+ *title* : string
6386+ the legend title
6387+
63506388Padding and spacing between various elements use following keywords
63516389parameters. The dimensions of these values are given as a fraction
63526390of the fontsize. Values from rcParams will be used if None.
@@ -6362,9 +6400,14 @@ def legend(*args, **kwargs):
63626400columnspacing the spacing between columns
63636401================ ==================================================================
63646402
6403+
63656404**Example:**
63666405
6367- .. plot:: mpl_examples/api/legend_demo.py"""
6406+ .. plot:: mpl_examples/api/legend_demo.py
6407+
6408+ Also see :ref:`plotting-guide-legend`.
6409+
6410+ """
63686411 ret = gca ().legend (* args , ** kwargs )
63696412 draw_if_interactive ()
63706413 return ret
0 commit comments