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

Skip to content

Removed deprecated code from gridspec.py #26885

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
Sep 26, 2023
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
1 change: 0 additions & 1 deletion ci/mypy-stubtest-allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ matplotlib.figure.Figure.set_tight_layout
matplotlib.cm.register_cmap
matplotlib.cm.unregister_cmap
matplotlib.collections.PolyCollection.span_where
matplotlib.gridspec.GridSpecBase.get_grid_positions

# 3.8 deprecations
matplotlib.cbook.get_sample_data
Expand Down
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/removals/26885-AD.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``raw`` parameter
~~~~~~~~~~~~~~~~~

... of `.GridSpecBase.get_grid_positions` is removed without replacements.
31 changes: 8 additions & 23 deletions lib/matplotlib/gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ def get_height_ratios(self):
"""
return self._row_height_ratios

@_api.delete_parameter("3.7", "raw")
def get_grid_positions(self, fig, raw=False):
def get_grid_positions(self, fig):
"""
Return the positions of the grid cells in figure coordinates.

Expand All @@ -151,11 +150,6 @@ def get_grid_positions(self, fig, raw=False):
fig : `~matplotlib.figure.Figure`
The figure the grid should be applied to. The subplot parameters
(margins and spacing between subplots) are taken from *fig*.
raw : bool, default: False
If *True*, the subplot parameters of the figure are not taken
into account. The grid spans the range [0, 1] in both directions
without margins and there is no space between grid cells. This is
used for constrained_layout.

Returns
-------
Expand All @@ -164,22 +158,13 @@ def get_grid_positions(self, fig, raw=False):
figure coordinates.
"""
nrows, ncols = self.get_geometry()

if raw:
left = 0.
right = 1.
bottom = 0.
top = 1.
wspace = 0.
hspace = 0.
else:
subplot_params = self.get_subplot_params(fig)
left = subplot_params.left
right = subplot_params.right
bottom = subplot_params.bottom
top = subplot_params.top
wspace = subplot_params.wspace
hspace = subplot_params.hspace
subplot_params = self.get_subplot_params(fig)
left = subplot_params.left
right = subplot_params.right
bottom = subplot_params.bottom
top = subplot_params.top
wspace = subplot_params.wspace
hspace = subplot_params.hspace
tot_width = right - left
tot_height = top - bottom

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/gridspec.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GridSpecBase:
def set_height_ratios(self, height_ratios: ArrayLike | None) -> None: ...
def get_height_ratios(self) -> ArrayLike: ...
def get_grid_positions(
self, fig: Figure, raw: bool = ...
self, fig: Figure
) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: ...
@staticmethod
def _check_gridspec_exists(figure: Figure, nrows: int, ncols: int) -> GridSpec: ...
Expand Down