8000 zorder of Artists not being respected when blitting with FuncAnimation · Issue #11369 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
zorder of Artists not being respected when blitting with FuncAnimation #11369
Closed
@jdollichon

Description

@jdollichon

Bugreport
The zorder of artists is not being respected, when using blitting while creating an animation with FuncAnimation. The order in which the user-function returning artists that have to be adapted implicity set the order in which they are updated and thus artists may actually be covered by other artists with lower zorder (see example below).

Code for reproduction

import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation

fig = plt.figure()
ax = plt.axes(xlim=(0, 2), ylim=(-2, 2))
red_sine, = ax.plot([], [], lw=5, color="r", zorder=2)
green_sine, = ax.plot([], [], lw=2, color="g", zorder=3)

def init():
    green_sine.set_data([], [])
    red_sine.set_data([], [])
    return green_sine, red_sine,

def ani(time):
    x = np.linspace(0, 2, 1000)
    y = np.sin(2 * np.pi * (x - 0.01 * time))
    green_sine.set_data(x, y)
    red_sine.set_data(x, y)
    return green_sine, red_sine,

anim = animation.FuncAnimation(fig, ani, init_func=init, frames=100, interval=2, blit=True)
plt.show()

Note: When adding pictures i noticed, that using the GUI-Buttons for saving yield expected results. On screen however results are as shown below. I briefly switched backends to 'TkAgg' without improvement.

Actual outcome
blit_bug

Expected outcome
blit_fix

Matplotlib version

  • Operating system: Windows 7
  • Matplotlib version: 2.2.2
  • Matplotlib backend: Qt5Agg
  • Python version: 3.5.5
    (virtual env via conda)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0