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

Skip to content

Commit 0b80a41

Browse files
committed
ENH: make get_position apply aspect
1 parent ba4142a commit 0b80a41

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -854,28 +854,43 @@ 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+
Return the a copy of the axes rectangle as a Bbox
859+
860+
Parameters
861+
----------
862+
original : bool
863+
If True return the original Axes position. If False
864+
(the default), then return the current position.
865+
866+
Returns
867+
-------
868+
ret : bbox
869+
"""
858870
if original:
859871
return self._originalPosition.frozen()
860872
else:
873+
self.apply_aspect()
861874
return self._position.frozen()
862875

863876
def set_position(self, pos, which='both'):
864-
"""Set the axes position
865-
866-
The expected shape of ``pos`` is::
877+
"""
878+
Set the axes position
867879
868-
pos = [left, bottom, width, height]
880+
Parameters
881+
----------
882+
pos : tuple of four floats or `~matplotlib.transforms.Bbox`
883+
The tuple is of the form::
869884
870-
in relative 0,1 coords, or *pos* can be a
871-
:class:`~matplotlib.transforms.Bbox`
885+
pos = [left, bottom, width, height]
872886
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`.
887+
in relative 0,1 figure coordinates, or *pos* can be a
888+
:class:`~matplotlib.transforms.Bbox`
876889
877-
Optional keyword arguments:
878-
*which*
890+
which : string
891+
There are two position variables: one which is ultimately
892+
used, but which may be modified by :meth:`apply_aspect`, and a
893+
second which is the starting point for :meth:`apply_aspect`.
879894
880895
========== ====================
881896
value description

lib/matplotlib/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
11651165

11661166
# transform each of the axes in parents using the new transform
11671167
for ax in parents:
1168-
new_posn = shrinking_trans.transform(ax.get_position())
1168+
new_posn = shrinking_trans.transform(ax.get_position(original=True))
11691169
new_posn = mtransforms.Bbox(new_posn)
11701170
ax.set_position(new_posn)
11711171
if parent_anchor is not False:

0 commit comments

Comments
 (0)