0

I made a plot with a simple cuvre that is shaded with datashade and ploted using bokeh and holoviews. I use streams with Buffer to update my data quickly without redrawing the full figure. The problem: when I push new data, the x and y limits does not update and the new data are out of the range of the figure.

Here is a reproducible example:

import json
# Importation des paramètres de conf
with open("./conf.json") as fid:
    conf = json.load(fid)
import panel as pn
pn.extension()
import holoviews as hv
hv.extension('bokeh', logo=False)
pn.extension()
import numpy as np
from holoviews.streams import Buffer
from holoviews.operation.datashader import datashade

class Dashboard:

    def __init__(self):
        arr = np.vstack([np.arange(100), np.random.random(100)]).T
        self.buf = Buffer(data=arr,
               length=100)
        ds = datashade(hv.DynamicMap(hv.Curve, streams=[self.buf]), streams=[hv.streams.PlotSize, hv.streams.RangeXY]).opts(
            min_height=400,
            max_height=600,
            tools=["save, undo, redo"],
            responsive=True,
            active_tools=['box_zoom'])
        self.button = pn.widgets.Button(name='Next buffer', button_type='primary', margin=(22, 10, 10, 10))
        self.button.on_click(self.update_data)
        self.col = pn.Column(ds, self.button)
        self.iter = 1

    def update_data(self, event):
        arr = np.vstack([np.arange(100), np.random.random(100)]).T
        self.buf.send(arr+self.iter)
        self.iter += 1

ds = Dashboard()
ds.col.servable()
ds.col.show(port=5007, threaded=True)

Expected result: When the interface first appear, we should see a curve with x from 0 to 100 and y random from 0 to 1. When you clic next, a new batch of data is sent. Those data range from 1 to 2. The plot is expected to update y limits from 1 to 2.

Actual result: All good but the y limits are still at 0 - 1, so no data shows up.

I am on MacOs (Apple M1, Ventura 13.4) Here are the requirements I used for this module:

jupyterlab==4.0.1
notebook==6.5.4
postgres==4.0
psycopg2-binary==2.9.6
scipy==1.10.1
numpy==1.24.3
pytest==7.4.0
pydub==0.25.1
sshtunnel==0.4.0
pytz==2023.3
build==0.10.0

Thanks!

EDIT - I tried removing the hv.streams.RangeXY in streams option of datashade. It now update correctly x and y lims but does not update shaded image anymore when I zoom in.

Cunningham
  • 178
  • 2
  • 10

0 Answers0