@@ -260,9 +260,15 @@ def __init__(self, parent, userax=True):
260260 self .outer_ax .tick_params = self .inner_ax .tick_params
261261 self .outer_ax .set_xticks = self .inner_ax .set_xticks
262262 self .outer_ax .set_yticks = self .inner_ax .set_yticks
263- for attr in ["get_position" , "set_position" , "set_aspect" ]:
263+ for attr in ["get_position" , "set_aspect" ,
264+ "_remove_method" , "_set_position" ,
265+ "set_position" ]:
264266 setattr (self , attr , getattr (self .outer_ax , attr ))
265267 self ._colorbar_info = None # used for mpl-created axes
268+ if hasattr (self .outer_ax , "get_subplotspec" ):
269+ attr = "get_subplotspec"
270+ setattr (self , attr , getattr (self .outer_ax , attr ))
271+
266272 if userax :
267273 self ._colorbar_info = 'user'
268274 # point the parent's methods all at this axes...
@@ -279,6 +285,7 @@ def draw(self, renderer):
279285 self .outer_ax .draw (renderer )
280286
281287
288+
282289class _ColorbarSpine (mspines .Spine ):
283290 def __init__ (self , axes ):
284291 self ._ax = axes
@@ -954,12 +961,11 @@ def set_alpha(self, alpha):
954961 def remove (self ):
955962 """
956963 Remove this colorbar from the figure.
957-
964+
958965 If the colorbar was created with ``use_gridspec=True`` the previous
959966 gridspec is restored.
960967 """
961- self .ax .inner_ax .remove ()
962- self .ax .outer_ax .remove ()
968+ self .ax .remove ()
963969
964970 self .mappable .callbacksSM .disconnect (self .mappable .colorbar_cid )
965971 self .mappable .colorbar = None
0 commit comments