Skip to content

Commit 8eb1b3a

Browse files
authored
Merge pull request matplotlib#20070 from anntzer/ad
Harmonize descriptions of the 'anchor' parameter.
2 parents 93e716d + 14745cd commit 8eb1b3a

File tree

3 files changed

+32
-53
lines changed

3 files changed

+32
-53
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,28 +1780,21 @@ def set_anchor(self, anchor, share=False):
17801780
17811781
Parameters
17821782
----------
1783-
anchor : 2-tuple of floats or {'C', 'SW', 'S', 'SE', ...}
1784-
The anchor position may be either:
1785-
1786-
- a sequence (*cx*, *cy*). *cx* and *cy* may range from 0
1787-
to 1, where 0 is left or bottom and 1 is right or top.
1788-
1789-
- a string using cardinal directions as abbreviation:
1790-
1791-
- 'C' for centered
1792-
- 'S' (south) for bottom-center
1793-
- 'SW' (south west) for bottom-left
1794-
- etc.
1795-
1796-
Here is an overview of the possible positions:
1797-
1798-
+------+------+------+
1799-
| 'NW' | 'N' | 'NE' |
1800-
+------+------+------+
1801-
| 'W' | 'C' | 'E' |
1802-
+------+------+------+
1803-
| 'SW' | 'S' | 'SE' |
1804-
+------+------+------+
1783+
anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', ...}
1784+
Either an (*x*, *y*) pair of relative coordinates (0 is left or
1785+
bottom, 1 is right or top), 'C' (center), or a cardinal direction
1786+
('SW', southwest, is bottom left, etc.). str inputs are shorthands
1787+
for (*x*, *y*) coordinates, as shown in the following table::
1788+
1789+
.. code-block:: none
1790+
1791+
+-----------------+-----------------+-----------------+
1792+
| 'NW' (0.0, 1.0) | 'N' (0.5, 1.0) | 'NE' (1.0, 1.0) |
1793+
+-----------------+-----------------+-----------------+
1794+
| 'W' (0.0, 0.5) | 'C' (0.5, 0.5) | 'E' (1.0, 0.5) |
1795+
+-----------------+-----------------+-----------------+
1796+
| 'SW' (0.0, 0.0) | 'S' (0.5, 0.0) | 'SE' (1.0, 0.0) |
1797+
+-----------------+-----------------+-----------------+
18051798
18061799
share : bool, default: False
18071800
If ``True``, apply the settings to all shared Axes.

lib/matplotlib/transforms.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -513,26 +513,21 @@ def inverse_transformed(self, transform):
513513

514514
def anchored(self, c, container=None):
515515
"""
516-
Return a copy of the `Bbox` shifted to position *c* within *container*.
516+
Return a copy of the `Bbox` anchored to *c* within *container*.
517517
518518
Parameters
519519
----------
520-
c : (float, float) or str
521-
May be either:
522-
523-
* A sequence (*cx*, *cy*) where *cx* and *cy* range from 0
524-
to 1, where 0 is left or bottom and 1 is right or top
525-
526-
* a string:
527-
- 'C' for centered
528-
- 'S' for bottom-center
529-
- 'SE' for bottom-left
530-
- 'E' for left
531-
- etc.
532-
520+
c : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', ...}
521+
Either an (*x*, *y*) pair of relative coordinates (0 is left or
522+
bottom, 1 is right or top), 'C' (center), or a cardinal direction
523+
('SW', southwest, is bottom left, etc.).
533524
container : `Bbox`, optional
534525
The box within which the `Bbox` is positioned; it defaults
535526
to the initial `Bbox`.
527+
528+
See Also
529+
--------
530+
.Axes.set_anchor
536531
"""
537532
if container is None:
538533
container = self

lib/mpl_toolkits/axes_grid1/axes_divider.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,14 @@ def set_anchor(self, anchor):
105105
"""
106106
Parameters
107107
----------
108-
anchor : {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'}
109-
anchor position
110-
111-
===== ============
112-
value description
113-
===== ============
114-
'C' Center
115-
'SW' bottom left
116-
'S' bottom
117-
'SE' bottom right
118-
'E' right
119-
'NE' top right
120-
'N' top
121-
'NW' top left
122-
'W' left
123-
===== ============
124-
108+
anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', ...}
109+
Either an (*x*, *y*) pair of relative coordinates (0 is left or
110+
bottom, 1 is right or top), 'C' (center), or a cardinal direction
111+
('SW', southwest, is bottom left, etc.).
112+
113+
See Also
114+
--------
115+
.Axes.set_anchor
125116
"""
126117
if len(anchor) != 2:
127118
_api.check_in_list(mtransforms.Bbox.coefs, anchor=anchor)

0 commit comments

Comments
 (0)