Hi awesome Holoviz community,
I’m experiencing some trouble when trying to zoom into plots generated from Dynamic Maps.
In order to replicate, simply use the code provided in the Working with Streaming Data.
The problem arises when one tries to use either zooming option (wheel, box,…).
After one interaction, the plot simply bricks, and even after refreshing, there is no chance to do any more zooms.
I’ve experimented using other types of stream (Boundsx, PointerXY, Tap,…) and they all work just as expected.
Example code:
import time
import numpy as np
import pandas as pd
import holoviews as hv
import streamz
import streamz.dataframe
from holoviews import opts
from holoviews.streams import Pipe, Buffer
hv.extension('bokeh')
simple_sdf = streamz.dataframe.Random(freq='10ms', interval='100ms')
print(simple_sdf.index)
simple_sdf.example.dtypes
sdf = (simple_sdf-0.5).cumsum()
hv.DynamicMap(hv.Curve, streams=[Buffer(sdf.x)]).opts(width=500, show_grid=True)
Replicate:
Run the code above and zoom into the plot more than once.
Hope anyone can help here.
Thanks in advance!!
I may have found an alternative solution by means of the Bokeh’s CDSStream object.
It’s a bit more involved to implement, but at least doesn’t break interactivity with the plots.
import numpy as np
import pandas as pd
import holoviews as hv
from holoviews import opts
from holoviews.streams import CDSStream
from bokeh.models.sources import ColumnDataSource
hv.extension('bokeh')
example = pd.DataFrame({'x': [], 'y': [], 'count': []}, columns=['x', 'y', 'count'])
brownian_source = ColumnDataSource(example)
dfstream = CDSStream(brownian_source)
curve_dmap = hv.DynamicMap(hv.Curve, streams=[dfstream])
point_dmap = hv.DynamicMap(hv.Points, streams=[dfstream])
def gen_brownian():
x, y, count = 0, 0, 0
while True:
x += np.random.randn()
y += np.random.randn()
count += 1
yield pd.DataFrame([(x, y, count)], columns=['x', 'y', 'count'])
brownian = gen_brownian()
for i in range(200):
brownian_df = next(brownian)
brownian_source = ColumnDataSource(brownian_df)
dfstream.event(data=brownian_source.data)
(curve_dmap * point_dmap).opts(
opts.Points(color='count', line_color='black', size=5, padding=0.1, xaxis=None, yaxis=None),
opts.Curve(line_width=1, color='black'))