Zooming issue on composite and rasterized (dynamic) plots when served on a website

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.

Recording showing the zoom issue
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)

A guess: maybe setting an aspect? Also, maybe dropping one of the min_* options and let the panel object handle the resizing instead of the hv object.

Also, your opts on scatter isn’t saved to a variable (if I’m not mistaken)

1 Like

Thanks for your answer, I have not been able to find any solution at the moment, neither by adjusting aspect, nor by removing any of the minimum dimensions I have put. I’ve been testing for hours and I can’t find any combination that satisfies the performance of a responsive design and the good use of the zoom feature when compositing dynamic rasterized graphs with other plot.

About the opts, you don’t need to keep it again to a variable. When you call .opts from a “hv object” it will set internal values that you have settled. There is no problem in this side, all this settings are working properly.

Maybe you can file an issue with a minimal example on HoloViews / hvplot

This could be related.

Instead of setting aspect maybe set data_aspect? Not sure if there’s a difference
Increased tolerance for aspect divergence by philippjfr · Pull Request #4104 · holoviz/holoviews (github.com)