Skip to content

[Bug]: Funcanimation has some problem with vscode #21951

@dentistfrankchen

Description

@dentistfrankchen

Bug summary

THIS IS NOT A POST FOR COMMUNITY HELP.

THIS IS A BUG REPORT.

PLEASE DO NOT CLOSE BEFORE REPLICATION.

Code for reproduction

%matplotlib ipympl

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

fig, ax = plt.subplots()

XX=[1,2,3]
YY=[2,4,6]
line, = ax.plot(XX,YY)

ax.set_xlim(-2,100)
ax.set_ylim(-2,100)

num=0

def init():
    line.set_ydata(YY)
    line.set_xdata(XX)
    return line,

def animate(i):
    ii=0
    while ii!=3:
        XX[ii]+=1
        ii+=1

    '''for ii in XX:
        ii+=1'''
    line.set_ydata(YY)
    line.set_xdata(XX)
    return line,

ani = animation.FuncAnimation(
    fig, animate,init_func=init,interval=50, blit=True, save_count=50) #interval is millisecond

plt.show()

Actual outcome

the pic do not move.

Expected outcome

the pic should move.

Additional information

use while instead of for can solve this problem.

Operating system

windows 10

Matplotlib Version

3.5.1

Matplotlib Backend

ipympl

Python version

3.8.1

Jupyter version

3.0.16

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions