Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4290d6

Browse files
committed
FIX: fix overwrite
1 parent 0169c49 commit f4290d6

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

lib/matplotlib/colorbar.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,10 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
14791479
if parent_anchor is not False:
14801480
ax.set_anchor(parent_anchor)
14811481

1482+
print('Before', fig._get_draw_artists(fig.canvas.get_renderer()))
14821483
cax = fig.add_axes(pbcb, label="<colorbar>")
1484+
print('Added', cax)
1485+
print(fig._get_draw_artists(fig.canvas.get_renderer()))
14831486
for a in parents:
14841487
# tell the parent it has a colorbar
14851488
a._colorbars += [cax]

lib/matplotlib/figure.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
`SubPanel`
1010
A logical figure inside a figure, usually added to a figure or parent
11-
`SubPanel` with `.add_subpanel` or `.subpanels` methods.
11+
`SubPanel` with `.add_subpanel` or `.subpanels` methods.
1212
1313
`SubplotParams`
1414
Control the default spacing between subplots.
@@ -844,6 +844,7 @@ def _add_axes_internal(self, key, ax):
844844
ax._remove_method = self.delaxes
845845
self.stale = True
846846
ax.stale_callback = _stale_figure_callback
847+
print('Adding Internal', ax)
847848
return ax
848849

849850
@cbook._make_keyword_only("3.3", "sharex")
@@ -1163,13 +1164,18 @@ def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
11631164

11641165
# Store the value of gca so that we can set it back later on.
11651166
current_ax = self.gca()
1166-
1167+
artists = self._get_draw_artists(self.canvas.get_renderer())
1168+
print('Before', artists)
11671169
if cax is None:
11681170
if (use_gridspec and isinstance(ax, SubplotBase)
11691171
and not self.get_constrained_layout()):
11701172
cax, kw = cbar.make_axes_gridspec(ax, **kw)
11711173
else:
1174+
print('Here')
11721175
cax, kw = cbar.make_axes(ax, **kw)
1176+
artists = self._get_draw_artists(self.canvas.get_renderer())
1177+
print('After', artists)
1178+
print('cax out', cax)
11731179

11741180
# need to remove kws that cannot be passed to Colorbar
11751181
NON_COLORBAR_KEYS = ['fraction', 'pad', 'shrink', 'aspect', 'anchor',
@@ -2021,11 +2027,6 @@ def get_axes(self):
20212027
"""
20222028
return self._localaxes
20232029

2024-
def add_axes(self, *args, **kwargs):
2025-
ax = super().add_axes(*args, **kwargs)
2026-
self._localaxes += [ax]
2027-
return ax
2028-
20292030
axes = property(get_axes, doc="""
20302031
List of axes in the Figure. You can access and modify the axes
20312032
in the Figure through this list.
@@ -2643,12 +2644,6 @@ def set_figheight(self, val, forward=True):
26432644
"""
26442645
self.set_size_inches(self.get_figwidth(), val, forward=forward)
26452646

2646-
def add_axes(self, *args, **kwargs):
2647-
ax = super().add_axes(*args, **kwargs)
2648-
self._localaxes += [ax]
2649-
return ax
2650-
2651-
26522647
def clf(self, keep_observers=False):
26532648
"""
26542649
Clear the figure.
@@ -2695,6 +2690,7 @@ def draw(self, renderer):
26952690
return
26962691

26972692
artists = self._get_draw_artists(renderer)
2693+
print('artists', artists)
26982694

26992695
try:
27002696
renderer.open_group('figure', gid=self.get_gid())

0 commit comments

Comments
 (0)