@@ -260,7 +260,6 @@ def __init__(self, parent, userax=True):
260
260
parent .remove ()
261
261
else :
262
262
outer_ax = parent
263
-
264
263
inner_ax = outer_ax .inset_axes ([0 , 0 , 1 , 1 ])
265
264
self .__dict__ .update (inner_ax .__dict__ )
266
265
@@ -285,6 +284,32 @@ def _set_inner_bounds(self, bounds):
285
284
self .inner_ax ._axes_locator = _TransformedBoundsLocator (
286
285
bounds , self .outer_ax .transAxes )
287
286
287
+ def cla (self ):
288
+ """
289
+ Reset the colorbar axes to be empty.
290
+ """
291
+ # need to low-level manipulate the stacks because we
292
+ # are just swapping places here. We don't need to
293
+ # set transforms etc...
294
+ self .inner_ax .cla ()
295
+ self .outer_ax .cla ()
296
+ self .figure ._axstack .add (self )
297
+ self .figure ._axstack .remove (self .outer_ax )
298
+ self .figure ._localaxes .add (self )
299
+ self .figure ._localaxes .remove (self .outer_ax )
300
+
301
+ self .__dict__ .update (self .outer_ax .__dict__ )
302
+ self .inner_ax .remove ()
303
+ del self .inner_ax
304
+ del self .outer_ax
305
+
306
+ self .xaxis .set_visible (True )
307
+ self .yaxis .set_visible (True )
308
+ for spine in self .spines .values ():
309
+ spine .set_visible (True )
310
+
311
+ self .set_facecolor (mpl .rcParams ['axes.facecolor' ])
312
+
288
313
289
314
class _ColorbarSpine (mspines .Spine ):
290
315
def __init__ (self , axes ):
@@ -1250,7 +1275,12 @@ def update_normal(self, mappable):
1250
1275
self .norm = mappable .norm
1251
1276
self ._reset_locator_formatter_scale ()
1252
1277
1253
- self .draw_all ()
1278
+ try :
1279
+ self .draw_all ()
1280
+ except AttributeError :
1281
+ # update_normal sometimes is called when it shouldn't be..
1282
+ pass
1283
+
1254
1284
if isinstance (self .mappable , contour .ContourSet ):
1255
1285
CS = self .mappable
1256
1286
if not CS .filled :
0 commit comments