Skip to content

Commit c75b807

Browse files
authored
Merge pull request #14880 from barabanus/fix-animation-for-twin-plots
Fix animation blitting for plots with shared axes
2 parents 520b5f6 + 6e3e967 commit c75b807

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/matplotlib/animation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,12 +1216,18 @@ def _blit_draw(self, artists, bg_cache):
12161216
# Handles blitted drawing, which renders only the artists given instead
12171217
# of the entire figure.
12181218
updated_ax = []
1219+
1220+
# Enumerate artists to cache axes' backgrounds. We do not draw
1221+
# artists yet to not cache foreground from plots with shared axes
12191222
for a in artists:
12201223
# If we haven't cached the background for this axes object, do
12211224
# so now. This might not always be reliable, but it's an attempt
12221225
# to automate the process.
12231226
if a.axes not in bg_cache:
12241227
bg_cache[a.axes] = a.figure.canvas.copy_from_bbox(a.axes.bbox)
1228+
1229+
# Make a separate pass to draw foreground
1230+
for a in artists:
12251231
a.axes.draw_artist(a)
12261232
updated_ax.append(a.axes)
12271233

0 commit comments

Comments
 (0)