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

Skip to content

Commit 579475b

Browse files
authored
Merge pull request #20606 from anntzer/uncbaraxes
Dynamically generate CbarAxes.
2 parents 246a489 + 5de0a17 commit 579475b

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``axes_grid1.axes_grid.CbarAxes`` and ``axes_grid1.axisartist.CbarAxes``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
These classes are deprecated (they are now dynamically generated based on the
4+
owning axes class).

lib/mpl_toolkits/axes_grid1/axes_grid.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import numpy as np
55

6-
from matplotlib import _api
6+
from matplotlib import _api, cbook
77
from matplotlib.gridspec import SubplotSpec
88

99
from .axes_divider import Size, SubplotDivider, Divider
@@ -43,10 +43,14 @@ def cla(self):
4343
self.orientation = orientation
4444

4545

46+
@_api.deprecated("3.5")
4647
class CbarAxes(CbarAxesBase, Axes):
4748
pass
4849

4950

51+
_cbaraxes_class_factory = cbook._make_class_factory(CbarAxesBase, "Cbar{}")
52+
53+
5054
class Grid:
5155
"""
5256
A grid of Axes.
@@ -310,8 +314,6 @@ def get_vsize_hsize(self):
310314
class ImageGrid(Grid):
311315
# docstring inherited
312316

313-
_defaultCbarAxesClass = CbarAxes
314-
315317
def __init__(self, fig,
316318
rect,
317319
nrows_ncols,
@@ -416,7 +418,7 @@ def _init_locators(self):
416418
else:
417419
self._colorbar_pad = self._vert_pad_size.fixed_size
418420
self.cbar_axes = [
419-
self._defaultCbarAxesClass(
421+
_cbaraxes_class_factory(self._defaultAxesClass)(
420422
self.axes_all[0].figure, self._divider.get_position(),
421423
orientation=self._colorbar_location)
422424
for _ in range(self.ngrids)]

lib/mpl_toolkits/axisartist/axes_grid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from matplotlib import _api
12
import mpl_toolkits.axes_grid1.axes_grid as axes_grid_orig
23
from .axislines import Axes
34

45

6+
@_api.deprecated("3.5")
57
class CbarAxes(axes_grid_orig.CbarAxesBase, Axes):
68
pass
79

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

1315
class ImageGrid(axes_grid_orig.ImageGrid):
1416
_defaultAxesClass = Axes
15-
_defaultCbarAxesClass = CbarAxes
1617

1718

1819
AxesGrid = ImageGrid

0 commit comments

Comments
 (0)