Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 40eb83f

Browse filesBrowse files
authored
Merge pull request #9951 from timhoffm/doc-axes-position
Improve documentation on Axes position
2 parents 542f7e6 + 5c9b102 commit 40eb83f
Copy full SHA for 40eb83f

File tree

Expand file treeCollapse file tree

1 file changed

+38
-24
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+38
-24
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+38-24Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -854,36 +854,44 @@ def _update_transScale(self):
854854
pass
855855

856856
def get_position(self, original=False):
857-
'Return the a copy of the axes rectangle as a Bbox'
857+
"""
858+
Get a copy of the axes rectangle as a `.Bbox`.
859+
860+
Parameters
861+
----------
862+
original : bool
863+
If ``True``, return the original position. Otherwise return the
864+
active position. For an explanation of the positions see
865+
`.set_position`.
866+
867+
Returns
868+
-------
869+
pos : `.Bbox`
870+
871+
"""
858872
if original:
859873
return self._originalPosition.frozen()
860874
else:
861875
return self._position.frozen()
862876

863877
def set_position(self, pos, which='both'):
864-
"""Set the axes position
865-
866-
The expected shape of ``pos`` is::
878+
"""
879+
Set the axes position.
867880
868-
pos = [left, bottom, width, height]
881+
Axes have two position attributes. The 'original' position is the
882+
position allocated for the Axes. The 'active' position is the
883+
position the Axes is actually drawn at. These positions are usually
884+
the same unless a fixed aspect is set to the Axes. See `.set_aspect`
885+
for details.
869886
870-
in relative 0,1 coords, or *pos* can be a
871-
:class:`~matplotlib.transforms.Bbox`
887+
Parameters
888+
----------
889+
pos : [left, bottom, width, height] or `~matplotlib.transforms.Bbox`
890+
The new position of the in `.Figure` coordinates.
872891
873-
There are two position variables: one which is ultimately
874-
used, but which may be modified by :meth:`apply_aspect`, and a
875-
second which is the starting point for :meth:`apply_aspect`.
892+
which : ['both' | 'active' | 'original'], optional
893+
Determines which position variables to change.
876894
877-
Optional keyword arguments:
878-
*which*
879-
880-
========== ====================
881-
value description
882-
========== ====================
883-
'active' to change the first
884-
'original' to change the second
885-
'both' to change both
886-
========== ====================
887895
"""
888896
if not isinstance(pos, mtransforms.BboxBase):
889897
pos = mtransforms.Bbox.from_bounds(*pos)
@@ -894,7 +902,12 @@ def set_position(self, pos, which='both'):
894902
self.stale = True
895903

896904
def reset_position(self):
897-
"""Make the original position the active position"""
905+
"""
906+
Reset the active position to the original position.
907+
908+
This resets the a possible position change due to aspect constraints.
909+
For an explanation of the positions see `.set_position`.
910+
"""
898911
pos = self.get_position(original=True)
899912
self.set_position(pos, which='active')
900913

@@ -917,7 +930,7 @@ def set_axes_locator(self, locator):
917930

918931
def get_axes_locator(self):
919932
"""
920-
return axes_locator
933+
Return the axes_locator.
921934
"""
922935
return self._axes_locator
923936

@@ -1114,10 +1127,11 @@ def axesPatch(self):
11141127
return self.patch
11151128

11161129
def clear(self):
1117-
"""clear the axes"""
1130+
"""Clear the axes."""
11181131
self.cla()
11191132

11201133
def get_facecolor(self):
1134+
"""Get the Axes facecolor."""
11211135
return self.patch.get_facecolor()
11221136
get_fc = get_facecolor
11231137

@@ -1226,7 +1240,7 @@ def ishold(self):
12261240
@cbook.deprecated("2.0", message=_hold_msg)
12271241
def hold(self, b=None):
12281242
"""
1229-
Set the hold state
1243+
Set the hold state.
12301244
12311245
The ``hold`` mechanism is deprecated and will be removed in
12321246
v3.0. The behavior will remain consistent with the

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.