Hi everyone,
I’m experiencing an issue with zooming on composite graphs when one of them is rasterized and dynamic. I have a line plot and a rasterized scatter plot and when I try to zoom in, it bounces back and resets the zoom level. Interestingly, this issue only occurs when I serve the application on a website using pn.serve, and not when I run it in a Jupyter notebook.
Image 1: Recording showing the zoom issue
I’ve done some research and found that defining a frame_width can solve the problem. However, this solution causes me to lose the responsive design that I’ve implemented in my application. I’ve tried using hvplot and holoviews to generate the scatter and the results are the same.
This code snippet is responsible for generating the graphs:
# Line plot grouped by channel
line_plot = df.hvplot.line(x='date', y='temperature', groupby='channel', responsive=True, min_height=400, min_width=600)
# Rasterized scatter plot using hvplot
scatter_plot = df.hvplot.scatter(x='date', y='temperature', rasterize=True, responsive=True, min_height=400, min_width=600,
aggregator=ds.mean('temperature'), dynspread=True)
scatter_plot.opts(cmap=cmap_temps, colorbar=True, clim=(0,30), alpha=0.35, tools=[''])
composite_plot = line_plot * scatter_plot
# Fixing the frame_width solves the zoom problem but I lost the responsive layout this way
#composite_plot.opts(frame_width=600)
plot_panel = pn.panel(composite_plot, widget_location='bottom', sizing_mode="stretch_width", linked_axes=False)
# In the jupyter notebook the zoom is working right
#plot_panel.servable()
# This problem only happens when visiting the graph in a web
pn.serve(plot_panel, show=False)
Is there another way to fix this issue without losing the responsive design?
The packages version I’m using:
holoviews: 1.15.4
hvplot: 0.8.3
datashader: 0.14.4
bokeh: 2.4.3
Thank you for your help! I really appreciate it. I’ve attached an ipynb file that reproduces the problem
rasterize-zoom-problem.ipynb (9.2 KB)