Skip to content

elizamanelli/dynamic_live_plot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dynamic_live_plot

Dynamic Live Plot is a simple way to plot data live and nonblocking. It is capable of dynamically adding and removing plots and graph glyphs during runtime. This is especially useful, if you do not know, which data will occour during runtime. This might be the case in a sensornetwork, where nodes may emerge, or disappear.

Its usage is extremely simplyfied. By calling just one method, plots can be updated by new data. Inbetween these updates of the plots, blocking computation can be done without stopping the live plot from working.

alt tag

The software depends on Python Bokeh. It strongly utilizes features of Bokeh like its server or "next tick callbacks". Its main class basically is an abstraction of embedding Bokeh Server as a library (also see the standalone_embed.py). To make the update calls non-blocking it extends threading.Thread.

Usage

BokehLivePlot

The only class method is push_data(). Its purpose is to tell BokehLivePlot which data to plot. It accepts a nested dictionary as argument:

  • Outer dictionary: Figures to plot
  • Inner dictionary: Lines of data, represented by numpy arrays (which is recommended by Python Bokeh)

Following example shows the usage of the class BokehLivePlot:

# import bokeh_live_plot
from bokeh_live_plot import BokehLivePlot
import time
# create BokehLivePlot object
myplot = BokehLivePlot()
# inject data for plotting
myplot.push_d(dict(FirstPlot=dict(plotA=np.array([0.1, 0.2, 0.3]), plotb=np.array([0.2, 0.3, 0.4]))
# do blocking computation (maybe for data acquisition)
time.sleep(.2)
# inject further data for plotting 
myplot.push_d(dict("FirstPlot"=dict("plotA=np.array([0.3, 0.2, 0.1]), plotb=np.array([0.4, 0.2, 0.3]))

JupyterLivePlot

The easiest way to find out about JupyterLivePlot is the following

  • clone or download this repository and cd to the bokeh folder (git clone https://github.com/ticktronaut/dynamic_live_plot.git && cd dynamic_live_plot/bokeh)
  • start a jupyter server in this directory (jupyter-server)
  • launch the jupyter_live_plot_sample.ipynb dictionary for further details on the usage of JupyterLivePlot

Requirements

BokehLivePlot strongly depends on Python Bokeh, which is licensed under BSD 3-Clause.

Quick test

Clone (or download, if desired) the repository:

git clone https://github.com/ticktronaut/dynamic_live_plot.git

Go to the directory, that contains the code:

cd bokeh

Launch the sample script (tested on Python 3.6):

python blp_sample.py

About

Dynamic Live Charts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 66.0%
  • Python 34.0%