Skip to content

Commit e94d77c

Browse files
committed
Make subplot_adjust work and remove work
1 parent aaaee32 commit e94d77c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/matplotlib/colorbar.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,14 @@ def __init__(self, parent, userax=True):
278278
self.outer_ax.tick_params = self.inner_ax.tick_params
279279
self.outer_ax.set_xticks = self.inner_ax.set_xticks
280280
self.outer_ax.set_yticks = self.inner_ax.set_yticks
281-
for attr in ["get_position", "set_position", "set_aspect"]:
281+
for attr in ["get_position", "set_aspect",
282+
"_remove_method", "_set_position",
283+
"set_position"]:
282284
setattr(self, attr, getattr(self.outer_ax, attr))
285+
if hasattr(self.outer_ax, "get_subplotspec"):
286+
attr = "get_subplotspec"
287+
setattr(self, attr, getattr(self.outer_ax, attr))
288+
283289
if userax:
284290
# point the parent's methods all at this axes...
285291
parent.__dict__ = self.__dict__
@@ -295,6 +301,7 @@ def draw(self, renderer):
295301
self.outer_ax.draw(renderer)
296302

297303

304+
298305
class _ColorbarSpine(mspines.Spine):
299306
def __init__(self, axes):
300307
self._ax = axes
@@ -883,8 +890,7 @@ def set_alpha(self, alpha):
883890

884891
def remove(self):
885892
"""Remove this colorbar from the figure."""
886-
self.ax.inner_ax.remove()
887-
self.ax.outer_ax.remove()
893+
self.ax.remove()
888894

889895
def _ticker(self, locator, formatter):
890896
"""

lib/matplotlib/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ def subplots_adjust(self, left=None, bottom=None, right=None, top=None,
12091209
"disabling constrained_layout.")
12101210
self.subplotpars.update(left, bottom, right, top, wspace, hspace)
12111211
for ax in self.axes:
1212-
if isinstance(ax, SubplotBase):
1212+
if hasattr(ax, 'get_subplotspec'):
12131213
ax._set_position(ax.get_subplotspec().get_position(self))
12141214
self.stale = True
12151215

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy