@@ -389,8 +389,7 @@ class ColorbarBase:
389389
390390 n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize
391391
392- @_api .make_keyword_only ("3.3" , "cmap" )
393- def __init__ (self , ax , cmap = None ,
392+ def __init__ (self , ax , * , cmap = None ,
394393 norm = None ,
395394 alpha = None ,
396395 values = None ,
@@ -1141,19 +1140,6 @@ def _short_axis(self):
11411140 return self .ax .yaxis
11421141
11431142
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-
11571143class Colorbar (ColorbarBase ):
11581144 """
11591145 This class connects a `ColorbarBase` to a `~.cm.ScalarMappable`
@@ -1171,18 +1157,15 @@ def __init__(self, ax, mappable, **kwargs):
11711157 mappable .autoscale_None ()
11721158
11731159 self .mappable = mappable
1174- _add_disjoint_kwargs ( kwargs , cmap = mappable .cmap , norm = mappable .norm )
1160+ kwargs . update ({ " cmap" : mappable .cmap , " norm" : mappable .norm } )
11751161
11761162 if isinstance (mappable , contour .ContourSet ):
11771163 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 })
11861169 kwargs .setdefault (
11871170 'ticks' , ticker .FixedLocator (cs .levels , nbins = 10 ))
11881171 super ().__init__ (ax , ** kwargs )
@@ -1192,24 +1175,13 @@ def __init__(self, ax, mappable, **kwargs):
11921175 if getattr (mappable .cmap , 'colorbar_extend' , False ) is not False :
11931176 kwargs .setdefault ('extend' , mappable .cmap .colorbar_extend )
11941177 if isinstance (mappable , martist .Artist ):
1195- _add_disjoint_kwargs ( kwargs , alpha = mappable .get_alpha ())
1178+ kwargs . update ({ " alpha" : mappable .get_alpha ()} )
11961179 super ().__init__ (ax , ** kwargs )
11971180
11981181 mappable .colorbar = self
11991182 mappable .colorbar_cid = mappable .callbacksSM .connect (
12001183 'changed' , self .update_normal )
12011184
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-
12131185 def add_lines (self , CS , erase = True ):
12141186 """
12151187 Add the lines from a non-filled `~.contour.ContourSet` to the colorbar.
@@ -1257,47 +1229,6 @@ def update_normal(self, mappable):
12571229 self .add_lines (CS )
12581230 self .stale = True
12591231
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-
13011232 def remove (self ):
13021233 """
13031234 Remove this colorbar from the figure.
0 commit comments