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

Skip to content

Running animation in Jupither #12952

Closed
@mg64ve

Description

@mg64ve

Bug report

Just trying to run an animation example in Jupyter fails

I am not getting any error. I can only see an empty figure with both axis.
No error in the logs.

Code for reproduction

%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation

fig, ax = plt.subplots()
xdata, ydata = [], []
ln, = plt.plot([], [], 'ro', animated=True)

def init():
    ax.set_xlim(0, 2*np.pi)
    ax.set_ylim(-1, 1)
    return ln,

def update(frame):
    xdata.append(frame)
    ydata.append(np.sin(frame))
    ln.set_data(xdata, ydata)
    return ln,

ani = FuncAnimation(fig, update, frames=np.linspace(0, 2*np.pi, 128),
                    init_func=init, blit=True)```

Actual outcome
Empty graph with axis but no value.

Console log

[W 12:10:24.759 NotebookApp] Clearing invalid/expired login cookie username-localhost-8888
[W 12:10:24.761 NotebookApp] Forbidden
[W 12:10:24.762 NotebookApp] 403 GET /api/sessions?_=1544334916656 (172.17.0.1) 4.60ms referer=http://localhost:8888/tree
[W 12:10:24.765 NotebookApp] Clearing invalid/expired login cookie username-localhost-8888
[W 12:10:24.766 NotebookApp] Forbidden
[W 12:10:24.767 NotebookApp] 403 GET /api/terminals?_=1544334916657 (172.17.0.1) 2.31ms referer=http://localhost:8888/tree
[I 12:10:33.460 NotebookApp] 302 GET /?token=c5048efec4dfe835a7296117127d4afe6945ba3016d894fd (172.17.0.1) 0.56ms
[I 12:10:39.531 NotebookApp] Writing notebook-signing key to /home/fastai/.local/share/jupyter/notebook_secret
[W 12:10:39.532 NotebookApp] Notebook Untitled1.ipynb is not trusted
[I 12:10:39.709 NotebookApp] Kernel started: 2f8cd46b-2aca-489f-ad74-7153126210b6
[I 12:10:40.161 NotebookApp] Adapting to protocol v5.1 for kernel 2f8cd46b-2aca-489f-ad74-7153126210b6
[I 12:11:14.693 NotebookApp] 302 GET /tree (172.17.0.1) 0.93ms
[I 12:12:41.516 NotebookApp] Saving file at /Untitled1.ipynb
[I 12:15:55.983 NotebookApp] Saving file at /Untitled1.ipynb

Expected outcome

I would expect and animated stream with sin function.

Matplotlib version

  • Operating system: Ubuntu docker image running on Centos 7.5.1804

  • Matplotlib version: 2.2.2

  • Matplotlib backend (print(matplotlib.get_backend())): nbAgg

  • Python version: 3.6.7

  • Jupyter version (if applicable): 5.7.2

  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions