Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ziofil/live_plot

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
8 Commits
 
 
 
 
 
 

Repository files navigation

live_plot

A jupyter-lab function for updating a plot dynamically in-place.

Disclaimer

Live plot covers only pyplot.plot (for now) and requires some explicit imports. It works with jupyter_lab on my mac, I haven't tested it in any other environemnt. You are welcome to create pull requests.

The working principle is simple: create a loop in which you populate a dictionary with the data you want to plot. Use the keys to label different datasets. Still within the loop, pass it to live_plot, sit back and watch.

Example

After importing the required libraries and defining the live_plot function (see example notebook), populate the dictionary in a loop. Better still, use a defaultdict to return an empty list the first time you use a new key:

import numpy as np
from collections import defaultdict

data = defaultdict(list)

for i in range(100):
    data['foo'].append(np.sin(i/10) + 0.1*np.random.random())
    data['bar'].append(np.random.random()+0.3)
    live_plot(data)

you should observe this in the cell output (the framerate will depend on the speed of the loop)

live plot animation

Make sure you create a few cells below the animation, otherwise the view snaps back into place and it's a bit annoying.

About

A jupyter-lab function for updating a plot dynamically in-place.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.