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

Skip to content

v3.3.0 Regression, Animation draws artists multiple times. #19040

@has2k1

Description

@has2k1

Bug report

Bug summary

The Animation classes ArtistAnimation and FunAnimation over draw onto the figure causing thick lines and "blocky" texts. This is a regression that ships in v3.3.0 (i.e v3.2.2 is good) and is still present in v3.3.3.

Code for reproduction

import itertools

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

# for animation in the notebook
from matplotlib import rc
rc('animation', html='html5')

def data_gen():
    for cnt in itertools.count():
        t = cnt / 10
        yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)


def init():
    ax.set_ylim(-1.1, 1.1)
    ax.set_xlim(0, 10)
    del xdata[:]
    del ydata[:]
    line.set_data(xdata, ydata)
    return line,

fig, ax = plt.subplots()
fig.set_size_inches(8, 6)
line, = ax.plot([], [], lw=2)
ax.grid()
xdata, ydata = [], []


def run(data):
    # update the data
    t, y = data
    xdata.append(t)
    ydata.append(y)
    xmin, xmax = ax.get_xlim()

    if t >= xmax:
        ax.set_xlim(xmin, 2*xmax)
        ax.figure.canvas.draw()
    line.set_data(xdata, ydata)

    return line,

ani = animation.FuncAnimation(fig, run, data_gen, interval=10, init_func=init)
ani

Actual outcome (v3.3.3)

bad-v3 3 3

Expected outcome (v3.2.2)

good-v3 2 2

The regression is clearly visible for the ticks and tick labels and less visible (in above example) is that it affects the plotting and legend too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions