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

Skip to content

Commit 78f204d

Browse files
authored
Merge pull request #11001 from jklymak/doc-improve-legend-docstring
DOC: improve legend bbox_to_anchor description
2 parents 8c3a3f9 + b9f7c0d commit 78f204d

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

lib/matplotlib/legend.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,26 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
130130
corner of the legend in axes coordinates (in which case
131131
``bbox_to_anchor`` will be ignored).
132132
133-
bbox_to_anchor : `.BboxBase` or pair of floats
134-
Specify any arbitrary location for the legend in `bbox_transform`
135-
coordinates (default Axes coordinates).
136-
137-
For example, to put the legend's upper right hand corner in the
138-
center of the axes the following keywords can be used::
133+
bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats
134+
Box that is used to position the legend in conjunction with *loc*.
135+
Defaults to `axes.bbox` (if called as a method to `.Axes.legend`) or
136+
`figure.bbox` (if `.Figure.legend`). This argument allows arbitrary
137+
placement of the legend.
138+
139+
Bbox coordinates are interpreted in the coordinate system given by
140+
`bbox_transform`, with the default transform
141+
Axes or Figure coordinates, depending on which ``legend`` is called.
142+
143+
If a 4-tuple or `.BboxBase` is given, then it specifies the bbox
144+
``(x, y, width, height)`` that the legend is placed in.
145+
To put the legend in the best location in the bottom right
146+
quadrant of the axes (or figure)::
147+
148+
loc='best', bbox_to_anchor=(0.5, 0., 0.5, 0.5)
149+
150+
A 2-tuple ``(x, y)`` places the corner of the legend specified by *loc* at
151+
x, y. For example, to put the legend's upper right-hand corner in the
152+
center of the axes (or figure) the following keywords can be used::
139153
140154
loc='upper right', bbox_to_anchor=(0.5, 0.5)
141155

0 commit comments

Comments
 (0)