Missing datapoints when using hvplot,line

I am rendering a time series using hvplot.line. When zooming in on the plot, I noticed some of the lines were disappearing where there should be data points. The lines are disappearing as the zoom increases. How can I control or avoid that?

This behavior is more clear when overlaying line- and scatter-plots of the same dataset.
The following code should reproduce the issue:

import xarray as xr
import holoviews as hv
import hvplot.xarray

url = "https://thredds.met.no/thredds/dodsC/alertness/YOPP_supersite/obs/utqiagvik/utqiagvik_obs_timeSeries_20180701_20180930.nc"
ds = xr.open_dataset(url)

# the following line plot which has data disappearing as we zoom in
ds['snd'].hvplot.line(x='time01')

# overlay showing missing data points in the line plot:
hv.Overlay([ds['snd'].hvplot.line(x='time01'), 
            ds['snd'].hvplot.scatter(x='time01')]).opts(show_grid=True)

I have a hard time recreating this is it possible to make a screen recording?

I tried to record an example here: No title available. Video i...

It seems the issue is related to the Y limit on the plot - when I fine tune the Y zoom to let the data “fit” in the plot canvas, then all the points are connected and the line plot is representative of the dataset - otherwise, the line plot is removing lines where actual data exist.

By looking at it, this is because it is only a single value surrounded by nan values. A line needs two points to be shown.

Can you check the data if this is the case?

Yes, that is exactly it! Thank you so much for clarifying the behavior. It is intuitive and visible when there is a large gap large data - gap in the data, but It is somehow confusing to see lines disappearing when zooming in. If I understood, this means that the line is shown because there is a sort of downsampling when zoomed out? why if I “adjust” the y-lim in the plot the NaN is ignored and a line is plotted?

There is no downsampling happening; what is happening at the end of your video should not happen.

What versions of Bokeh and HoloViews are you using? Can you try hv.renderer('bokeh').webgl = False and see if this changes the behavior?

Using hv.renderer('bokeh').webgl = False - I no longer see lines disappearing!

I think this should be fixed on the latest version of Bokeh.

Wonderful! Thank you so much for your help.
I am running:

Python 3.11.6 | packaged by conda-forge | (main, Oct  3 2023, 10:40:35) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bokeh
>>> bokeh.__version__
'3.3.3'

I will try to install the 3.4.0.dev5 version and see if that fixes it.

1 Like