@@ -389,8 +389,7 @@ class ColorbarBase:
389
389
390
390
n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize
391
391
392
- @_api .make_keyword_only ("3.3" , "cmap" )
393
- def __init__ (self , ax , cmap = None ,
392
+ def __init__ (self , ax , * , cmap = None ,
394
393
norm = None ,
395
394
alpha = None ,
396
395
values = None ,
@@ -1141,19 +1140,6 @@ def _short_axis(self):
1141
1140
return self .ax .yaxis
1142
1141
1143
1142
1144
- def _add_disjoint_kwargs (d , ** kwargs ):
1145
- """
1146
- Update dict *d* with entries in *kwargs*, which must be absent from *d*.
1147
- """
1148
- for k , v in kwargs .items ():
1149
- if k in d :
1150
- _api .warn_deprecated (
1151
- "3.3" , message = f"The { k !r} parameter to Colorbar has no "
1152
- "effect because it is overridden by the mappable; it is "
1153
- "deprecated since %(since)s and will be removed %(removal)s." )
1154
- d [k ] = v
1155
-
1156
-
1157
1143
class Colorbar (ColorbarBase ):
1158
1144
"""
1159
1145
This class connects a `ColorbarBase` to a `~.cm.ScalarMappable`
@@ -1171,18 +1157,15 @@ def __init__(self, ax, mappable, **kwargs):
1171
1157
mappable .autoscale_None ()
1172
1158
1173
1159
self .mappable = mappable
1174
- _add_disjoint_kwargs ( kwargs , cmap = mappable .cmap , norm = mappable .norm )
1160
+ kwargs . update ({ " cmap" : mappable .cmap , " norm" : mappable .norm } )
1175
1161
1176
1162
if isinstance (mappable , contour .ContourSet ):
1177
1163
cs = mappable
1178
- _add_disjoint_kwargs (
1179
- kwargs ,
1180
- alpha = cs .get_alpha (),
1181
- boundaries = cs ._levels ,
1182
- values = cs .cvalues ,
1183
- extend = cs .extend ,
1184
- filled = cs .filled ,
1185
- )
1164
+ kwargs .update ({"alpha" : cs .get_alpha (),
1165
+ "boundaries" : cs ._levels ,
1166
+ "values" : cs .cvalues ,
1167
+ "extend" : cs .extend ,
1168
+ "filled" : cs .filled })
1186
1169
kwargs .setdefault (
1187
1170
'ticks' , ticker .FixedLocator (cs .levels , nbins = 10 ))
1188
1171
super ().__init__ (ax , ** kwargs )
@@ -1192,24 +1175,13 @@ def __init__(self, ax, mappable, **kwargs):
1192
1175
if getattr (mappable .cmap , 'colorbar_extend' , False ) is not False :
1193
1176
kwargs .setdefault ('extend' , mappable .cmap .colorbar_extend )
1194
1177
if isinstance (mappable , martist .Artist ):
1195
- _add_disjoint_kwargs ( kwargs , alpha = mappable .get_alpha ())
1178
+ kwargs . update ({ " alpha" : mappable .get_alpha ()} )
1196
1179
super ().__init__ (ax , ** kwargs )
1197
1180
1198
1181
mappable .colorbar = self
1199
1182
mappable .colorbar_cid = mappable .callbacksSM .connect (
1200
1183
'changed' , self .update_normal )
1201
1184
1202
- @_api .deprecated ("3.3" , alternative = "update_normal" )
1203
- def on_mappable_changed (self , mappable ):
1204
- """
1205
- Update this colorbar to match the mappable's properties.
1206
-
1207
- Typically this is automatically registered as an event handler
1208
- by :func:`colorbar_factory` and should not be called manually.
1209
- """
1210
- _log .debug ('colorbar mappable changed' )
1211
- self .update_normal (mappable )
1212
-
1213
1185
def add_lines (self , CS , erase = True ):
1214
1186
"""
1215
1187
Add the lines from a non-filled `~.contour.ContourSet` to the colorbar.
@@ -1257,47 +1229,6 @@ def update_normal(self, mappable):
1257
1229
self .add_lines (CS )
1258
1230
self .stale = True
1259
1231
1260
- @_api .deprecated ("3.3" , alternative = "update_normal" )
1261
- def update_bruteforce (self , mappable ):
1262
- """
1263
- Destroy and rebuild the colorbar. This is
1264
- intended to become obsolete, and will probably be
1265
- deprecated and then removed. It is not called when
1266
- the pyplot.colorbar function or the Figure.colorbar
1267
- method are used to create the colorbar.
1268
- """
1269
- # We are using an ugly brute-force method: clearing and
1270
- # redrawing the whole thing. The problem is that if any
1271
- # properties have been changed by methods other than the
1272
- # colorbar methods, those changes will be lost.
1273
- self .ax .cla ()
1274
- self .locator = None
1275
- self .formatter = None
1276
-
1277
- # clearing the axes will delete outline, patch, solids, and lines:
1278
- for spine in self .ax .spines .values ():
1279
- spine .set_visible (False )
1280
- self .outline = self .ax .spines ['outline' ] = _ColorbarSpine (self .ax )
1281
- self .patch = mpatches .Polygon (
1282
- np .empty ((0 , 2 )),
1283
- color = mpl .rcParams ['axes.facecolor' ], linewidth = 0.01 , zorder = - 1 )
1284
- self .ax .add_artist (self .patch )
1285
- self .solids = None
1286
- self .lines = []
1287
- self .update_normal (mappable )
1288
- self .draw_all ()
1289
- if isinstance (self .mappable , contour .ContourSet ):
1290
- CS = self .mappable
1291
- if not CS .filled :
1292
- self .add_lines (CS )
1293
- #if self.lines is not None:
1294
- # tcolors = [c[0] for c in CS.tcolors]
1295
- # self.lines.set_color(tcolors)
1296
- #Fixme? Recalculate boundaries, ticks if vmin, vmax have changed.
1297
- #Fixme: Some refactoring may be needed; we should not
1298
- # be recalculating everything if there was a simple alpha
1299
- # change.
1300
-
1301
1232
def remove (self ):
1302
1233
"""
1303
1234
Remove this colorbar from the figure.
0 commit comments