@@ -245,9 +245,9 @@ def __init__(self, parent, userax=True):
245
245
True if the user passed `.Figure.colorbar` the axes manually.
246
246
"""
247
247
248
+ fig = parent .figure
248
249
if userax :
249
250
# copy position:
250
- fig = parent .figure
251
251
outer_ax = fig .add_axes (parent .get_position ())
252
252
# copy the locator if one exists:
253
253
outer_ax ._axes_locator = parent ._axes_locator
@@ -261,11 +261,17 @@ def __init__(self, parent, userax=True):
261
261
else :
262
262
outer_ax = parent
263
263
264
+ # swap axes in the stack:
265
+ fig ._localaxes .remove (outer_ax )
266
+ fig ._axstack .remove (outer_ax )
267
+ fig ._localaxes .add (self )
268
+ fig ._axstack .add (self )
264
269
inner_ax = outer_ax .inset_axes ([0 , 0 , 1 , 1 ])
265
270
self .__dict__ .update (inner_ax .__dict__ )
266
271
267
272
self .outer_ax = outer_ax
268
273
self .inner_ax = inner_ax
274
+
269
275
self .outer_ax .xaxis .set_visible (False )
270
276
self .outer_ax .yaxis .set_visible (False )
271
277
self .outer_ax .set_facecolor ('none' )
@@ -285,6 +291,9 @@ def _set_inner_bounds(self, bounds):
285
291
self .inner_ax ._axes_locator = _TransformedBoundsLocator (
286
292
bounds , self .outer_ax .transAxes )
287
293
294
+ def draw (self , renderer ):
295
+ self .outer_ax .draw (renderer )
296
+
288
297
289
298
class _ColorbarSpine (mspines .Spine ):
290
299
def __init__ (self , axes ):
0 commit comments