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

Skip to content

Dynamically generate CbarAxes. #20606

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
Jul 20, 2021
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
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations/20606-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``axes_grid1.axes_grid.CbarAxes`` and ``axes_grid1.axisartist.CbarAxes``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
These classes are deprecated (they are now dynamically generated based on the
owning axes class).
10 changes: 6 additions & 4 deletions lib/mpl_toolkits/axes_grid1/axes_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

from matplotlib import _api
from matplotlib import _api, cbook
from matplotlib.gridspec import SubplotSpec

from .axes_divider import Size, SubplotDivider, Divider
Expand Down Expand Up @@ -43,10 +43,14 @@ def cla(self):
self.orientation = orientation


@_api.deprecated("3.5")
class CbarAxes(CbarAxesBase, Axes):
pass


_cbaraxes_class_factory = cbook._make_class_factory(CbarAxesBase, "Cbar{}")


class Grid:
"""
A grid of Axes.
Expand Down Expand Up @@ -310,8 +314,6 @@ def get_vsize_hsize(self):
class ImageGrid(Grid):
# docstring inherited

_defaultCbarAxesClass = CbarAxes

def __init__(self, fig,
rect,
nrows_ncols,
Expand Down Expand Up @@ -416,7 +418,7 @@ def _init_locators(self):
else:
self._colorbar_pad = self._vert_pad_size.fixed_size
self.cbar_axes = [
self._defaultCbarAxesClass(
_cbaraxes_class_factory(self._defaultAxesClass)(
self.axes_all[0].figure, self._divider.get_position(),
orientation=self._colorbar_location)
for _ in range(self.ngrids)]
Expand Down
3 changes: 2 additions & 1 deletion lib/mpl_toolkits/axisartist/axes_grid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from matplotlib import _api
import mpl_toolkits.axes_grid1.axes_grid as axes_grid_orig
from .axislines import Axes


@_api.deprecated("3.5")
class CbarAxes(axes_grid_orig.CbarAxesBase, Axes):
pass

Expand All @@ -12,7 +14,6 @@ class Grid(axes_grid_orig.Grid):

class ImageGrid(axes_grid_orig.ImageGrid):
_defaultAxesClass = Axes
_defaultCbarAxesClass = CbarAxes


AxesGrid = ImageGrid