Streamz hvplot resets zoom and pan on each update

Hello!

I’m trying to get a streaming plot in my panel app.
Streamz seems very handy, using emit to push new values to the plot, but there is one annoying issue with it. On each new sample, the zoom and pan are reset, so it practically makes the whole control bar of the bokeh plot useless. Is there some way to make the zoom/pan remain when emitting new samples?

Basic example to reproduce:

import panel as pn
import hvplot.streamz  # noqa
from streamz.dataframe import Random
pn.extension("bokeh")
df = Random(interval='200ms', freq='50ms')

pn.Column(df.hvplot()).servable()

Just drag around a little and see that it resets every 200ms.

Best regards,
Fredrik

3 Likes

Hi I am suffering from the same problem.

from streamz.dataframe import DataFrame
example = pd.DataFrame([-200])
df = DataFrame(dfs, example=example)

import hvplot.streamz
df.hvplot()

If I zoom that is not keeping the state in the panel.

Zoom does not work with panel also.

import numpy as np

import holoviews as hv

import holoviews.plotting.bokeh

import streamz

import streamz.dataframe

renderer = hv.renderer(‘bokeh’)

from holoviews import opts

from holoviews.streams import Pipe, Buffer

hv.extension(‘bokeh’)

source_df = streamz.dataframe.Random(freq=‘5ms’, interval=‘100ms’)

sdf = (source_df-0.5).cumsum()

raw_dmap = hv.DynamicMap(hv.Curve, streams=[Buffer(sdf.x)])

smooth_dmap = hv.DynamicMap(hv.Curve, streams=[Buffer(sdf.x.rolling(‘50ms’).mean())])

dmap = hv.DynamicMap(hv.Dataset, streams=[Buffer(sdf.x, length=500)])

historgram = hv.operation.histogram(dmap, dimension=‘x’)

fig = (raw_dmap.relabel(‘raw’) * smooth_dmap.relabel(‘smooth’)).opts(

opts.Curve(width=500, show_grid=True))

fig = (raw_dmap.relabel(‘raw’) * smooth_dmap.relabel(‘smooth’)).opts(

opts.Curve(width=500, show_grid=True))

renderer.server_doc(fig)