Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cbc6bb2

Browse filesBrowse files
authored
Merge pull request #17175 from anntzer/axes_grid-colorbar
Further sync axes_grid colorbars with standard colorbars.
2 parents 912e814 + 1163bf5 commit cbc6bb2
Copy full SHA for cbc6bb2

File tree

Expand file treeCollapse file tree

3 files changed

+35
-28
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+35
-28
lines changed
Open diff view settings
Collapse file

‎doc/api/api_changes_3.3/deprecations.rst‎

Copy file name to clipboardExpand all lines: doc/api/api_changes_3.3/deprecations.rst
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -525,3 +525,8 @@ experimental and may change in the future.
525525
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
526526
These are unused and can be easily reproduced by other date tools.
527527
`.get_epoch` will return Matplotlib's epoch.
528+
529+
``axes_grid1.CbarAxes`` attributes
530+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
531+
The ``cbid`` and ``locator`` attribute are deprecated. Use
532+
``mappable.colorbar_cid`` and ``colorbar.locator``, as for standard colorbars.
Collapse file

‎lib/mpl_toolkits/axes_grid1/axes_grid.py‎

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/axes_grid.py
+29-19Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def _tick_only(ax, bottom_on, left_on):
1919

2020

2121
class CbarAxesBase:
22+
def __init__(self, *args, orientation, **kwargs):
23+
self.orientation = orientation
24+
self._default_label_on = True
25+
self._locator = None # deprecated.
26+
super().__init__(*args, **kwargs)
2227

2328
@cbook._rename_parameter("3.2", "locator", "ticks")
2429
def colorbar(self, mappable, *, ticks=None, **kwargs):
@@ -38,21 +43,30 @@ def colorbar(self, mappable, *, ticks=None, **kwargs):
3843
if ticks is None:
3944
ticks = ticker.MaxNLocator(5) # For backcompat.
4045
from .colorbar import Colorbar
46+
cb = Colorbar(
47+
self, mappable, orientation=orientation, ticks=ticks, **kwargs)
48+
self._cbid = mappable.callbacksSM.connect(
49+
'changed', cb.update_normal)
50+
mappable.colorbar = cb
51+
self._locator = cb.cbar_axis.get_major_locator()
4152
else:
42-
from matplotlib.colorbar import Colorbar
43-
cb = Colorbar(
44-
self, mappable, orientation=orientation, ticks=ticks, **kwargs)
45-
self._config_axes()
53+
cb = mpl.colorbar.colorbar_factory(
54+
self, mappable, orientation=orientation, ticks=ticks, **kwargs)
55+
self._cbid = mappable.colorbar_cid # deprecated.
56+
self._locator = cb.locator # deprecated.
4657

47-
self.cbid = mappable.callbacksSM.connect('changed', cb.update_normal)
48-
mappable.colorbar = cb
58+
self._config_axes()
59+
return cb
4960

50-
if mpl.rcParams["mpl_toolkits.legacy_colorbar"]:
51-
self.locator = cb.cbar_axis.get_major_locator()
52-
else:
53-
self.locator = cb.locator
61+
@cbook.deprecated("3.3", alternative="mappable.colorbar_cid")
62+
@property
63+
def cbid(self):
64+
return self._cbid
5465

55-
return cb
66+
@cbook.deprecated("3.3", alternative=".colorbar().locator")
67+
@property
68+
def locator(self):
69+
return self._locator
5670

5771
def _config_axes(self):
5872
"""Make an axes patch and outline."""
@@ -67,19 +81,15 @@ def toggle_label(self, b):
6781
axis = self.axis[self.orientation]
6882
axis.toggle(ticklabels=b, label=b)
6983

70-
71-
class CbarAxes(CbarAxesBase, Axes):
72-
def __init__(self, *args, orientation, **kwargs):
73-
self.orientation = orientation
74-
self._default_label_on = True
75-
self.locator = None
76-
super().__init__(*args, **kwargs)
77-
7884
def cla(self):
7985
super().cla()
8086
self._config_axes()
8187

8288

89+
class CbarAxes(CbarAxesBase, Axes):
90+
pass
91+
92+
8393
class Grid:
8494
"""
8595
A grid of Axes.
Collapse file

‎lib/mpl_toolkits/axisartist/axes_grid.py‎

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/axes_grid.py
+1-9Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33

44

55
class CbarAxes(axes_grid_orig.CbarAxesBase, Axes):
6-
def __init__(self, *args, orientation, **kwargs):
7-
self.orientation = orientation
8-
self._default_label_on = False
9-
self.locator = None
10-
super().__init__(*args, **kwargs)
11-
12-
def cla(self):
13-
super().cla()
14-
self._config_axes()
6+
pass
157

168

179
class Grid(axes_grid_orig.Grid):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.