11 Streaming Data ¶
"Streaming data" is data that is continuously generated, often by some external source like a remote website, a measuring device, or a simulator. This kind of data is common for financial time series, web server logs, scientific applications, and many other situations. We have seen how to visualize any data output by a callable in the Live Data user guide and we have also seen how to use the HoloViews stream system to push events in the user guide sections Responding to Events and Custom Interactivity .
This user guide shows a third way of building an interactive plot, using
and streams. Here, instead of pushing plot metadata (such as zoom ranges, user triggered events such as
and so on) to a
callback, the underlying data in the visualized elements are updated directly using a HoloViews
In particular, we will show how the HoloViews
streams can be used to work with streaming data sources without having to fetch or generate the data from inside the
callable. Apart from simply setting element data from outside a
, we will also explore ways of working with streaming data coordinated by the optional separate
library from Matt Rocklin, which can make building complex streaming pipelines much simpler.
Note that this page demonstrates functionality that requires a live, running Python server. When exported to a static HTML page as on the pyviz.org website, you will only see a single plot. When running this code as a Jupyter notebook, you should execute it cell by cell to see the effect of each operation in turn.
import time import numpy as np import pandas as pd import holoviews as hv from holoviews import opts, dim from holoviews.streams import Pipe, Buffer import streamz import streamz.dataframe hv.extension('bokeh') opts.defaults( opts.Curve(width=600), opts.Points(color=dim('count'), xaxis=None, yaxis=None, line_color='black', size=5), opts.RGB(width=600) )