@@ -19,6 +19,11 @@ def _tick_only(ax, bottom_on, left_on):
19
19
20
20
21
21
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 )
22
27
23
28
@cbook ._rename_parameter ("3.2" , "locator" , "ticks" )
24
29
def colorbar (self , mappable , * , ticks = None , ** kwargs ):
@@ -38,21 +43,30 @@ def colorbar(self, mappable, *, ticks=None, **kwargs):
38
43
if ticks is None :
39
44
ticks = ticker .MaxNLocator (5 ) # For backcompat.
40
45
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 ()
41
52
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.
46
57
47
- self .cbid = mappable . callbacksSM . connect ( 'changed' , cb . update_normal )
48
- mappable . colorbar = cb
58
+ self ._config_axes ( )
59
+ return cb
49
60
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
54
65
55
- return cb
66
+ @cbook .deprecated ("3.3" , alternative = ".colorbar().locator" )
67
+ @property
68
+ def locator (self ):
69
+ return self ._locator
56
70
57
71
def _config_axes (self ):
58
72
"""Make an axes patch and outline."""
@@ -67,19 +81,15 @@ def toggle_label(self, b):
67
81
axis = self .axis [self .orientation ]
68
82
axis .toggle (ticklabels = b , label = b )
69
83
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
-
78
84
def cla (self ):
79
85
super ().cla ()
80
86
self ._config_axes ()
81
87
82
88
89
+ class CbarAxes (CbarAxesBase , Axes ):
90
+ pass
91
+
92
+
83
93
class Grid :
84
94
"""
85
95
A grid of Axes.
0 commit comments