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

Skip to content

Sync SubplotDivider API with SubplotBase API changes. #18655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions doc/api/next_api_changes/deprecations/18564-AL.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
Subplot-related attributes and methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some ``SubplotBase`` attributes have been deprecated and/or moved to
`.SubplotSpec`: ``get_geometry`` (use `.SubplotBase.get_subplotspec`
instead), ``change_geometry`` (use `.SubplotBase.set_subplotspec` instead),
``is_first_row``, ``is_last_row``, ``is_first_col``, ``is_last_col`` (use the
corresponding methods on the `.SubplotSpec` instance instead), ``figbox`` (use
``ax.get_subplotspec().get_geometry(ax.figure)`` instead to recompute the
geometry, or ``ax.get_position()`` to read its current value), ``numRows``,
``numCols`` (use the ``nrows`` and ``ncols`` attribute on the `.GridSpec`
instead).
Some ``SubplotBase`` methods and attributes have been deprecated and/or moved
to `.SubplotSpec`: ``get_geometry`` (use `.SubplotBase.get_subplotspec`
instead), ``change_geometry`` (use `.SubplotBase.set_subplotspec`
instead), ``is_first_row``, ``is_last_row``, ``is_first_col``,
``is_last_col`` (use the corresponding methods on the `.SubplotSpec`
instance instead), ``update_params`` (now a no-op), ``figbox`` (use
``ax.get_subplotspec().get_geometry(ax.figure)`` instead to recompute
the geometry, or ``ax.get_position()`` to read its current value),
``numRows``, ``numCols`` (use the ``nrows`` and ``ncols`` attribute on the
`.GridSpec` instead). Likewise, the ``get_geometry``, ``change_geometry``,
``update_params``, and ``figbox`` methods/attributes of `.SubplotDivider` have
been deprecated, with similar replacements.

Axes constructor
~~~~~~~~~~~~~~~~
Expand Down
23 changes: 15 additions & 8 deletions lib/mpl_toolkits/axes_grid1/axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,27 +347,33 @@ def __init__(self, fig, *args, horizontal=None, vertical=None,
(2, 3, 4)).
"""
self.figure = fig
self._subplotspec = SubplotSpec._from_subplot_args(fig, args)
self.update_params() # sets self.figbox
super().__init__(fig, pos=self.figbox.bounds,
super().__init__(fig, [0, 0, 1, 1],
horizontal=horizontal or [], vertical=vertical or [],
aspect=aspect, anchor=anchor)
self.set_subplotspec(SubplotSpec._from_subplot_args(fig, args))

def get_position(self):
"""Return the bounds of the subplot box."""
self.update_params() # update self.figbox
return self.figbox.bounds
return self.get_subplotspec().get_position(self.figure).bounds

@cbook.deprecated("3.4")
@property
def figbox(self):
return self.get_subplotspec().get_position(self.figure)

@cbook.deprecated("3.4")
def update_params(self):
"""Update the subplot position from fig.subplotpars."""
self.figbox = self.get_subplotspec().get_position(self.figure)
pass

@cbook.deprecated(
"3.4", alternative="get_subplotspec",
addendum="(get_subplotspec returns a SubplotSpec instance.)")
def get_geometry(self):
"""Get the subplot geometry, e.g., (2, 2, 3)."""
rows, cols, num1, num2 = self.get_subplotspec().get_geometry()
return rows, cols, num1 + 1 # for compatibility

# COVERAGE NOTE: Never used internally or from examples
@cbook.deprecated("3.4", alternative="set_subplotspec")
def change_geometry(self, numrows, numcols, num):
"""Change subplot geometry, e.g., from (1, 1, 1) to (2, 2, 3)."""
self._subplotspec = GridSpec(numrows, numcols)[num-1]
Expand All @@ -381,6 +387,7 @@ def get_subplotspec(self):
def set_subplotspec(self, subplotspec):
"""Set the SubplotSpec instance."""
self._subplotspec = subplotspec
self.set_position(subplotspec.get_position(self.figure))


class AxesDivider(Divider):
Expand Down