Zooming should re-render elements for Trimesh


I’m using rasterise and TriMesh together with data shader to plot irregularly gridded data:

simplices = coupler_elements.loc[mesh.no_cyclic_elem]
nodes = gv.Points(coupler_data_df, vdims=["Ocean Hydr."])

trimesh = gv.TriMesh((simplices, nodes),
projected_trimesh = gv.project(trimesh, projection=ccrs.Robinson())
    # Tools:
    # Figure Height/Width:
    # Projection:
    # Colorbar:
    clabel="Hydrological Discharge in Ocean")

This works nicely, and I get a map. However, when I zoom in, the triangular elements aren’t re-rendered with the new resolution. I could have sworn I had this working before, but I can’t find the notebook I made… perhaps something like this would therefore be good to include in the documentation? I’d be happy to contribute an example!

Any hints would be appreciated! :slight_smile:

Failure to update a datashaded plot will usually result in error messages on your browser’s JavaScript console; try checking there to see what’s happening. One common reason for that behavior is not having the right extension installed. E.g. are you using JupyterLab without first running “jupyter labextension install @pyviz/jupyterlab_pyviz”?

Unfortunately no…? This might be interesting to look into. I had the following enabled in my Jupyterlab:

jupyter labextension list                           
JupyterLab v1.2.6
Known labextensions:
   app dir: /Users/pgierz/anaconda3/envs/fesom_viz/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v1.1.0  enabled  OK
        @pyviz/jupyterlab_pyviz v0.8.0  enabled  OK
        dask-labextension v1.1.0  enabled  OK

Turning off the dask-labextension resulted in the correct behaviour, and I’m able to zoom in again. However, I can imagine that for some tasks users might want to have both of these things active. I’m happy to provide logs if it helps with debugging; just let me know what you need.

I was hitting this same issue: zooming was working with rasterize=True with classic Jupyter notebook mode, but not with Jupyterlab.

I was starting my jupyterlab session with a base conda environment that had these extensions:

(base) rsignell@nid00017:~> jupyter labextension list
JupyterLab v3.2.8
        dask-labextension v5.2.0 enabled OK (python, dask_labextension)
        @jupyterlab/server-proxy v3.2.1 enabled OK
        @jupyter-widgets/jupyterlab-manager v3.0.1 enabled OK (python, jupyterlab_widgets)

and then I was selecting my “pangeo” kernel environment to run the notebook that had these extensions:

(pangeo) rsignell@nid00017:~> jupyter labextension list
JupyterLab v3.2.8
        ipyurl v0.1.2 enabled OK (python, ipyurl)
        ipyspin v0.1.5 enabled OK
        jupyter-leaflet v0.15.0 enabled OK
        @jupyterlab/server-proxy v3.2.1 enabled OK
        @jupyter-widgets/jupyterlab-manager v3.0.1 enabled OK (python, jupyterlab_widgets)
        @jupyter-server/resource-usage v0.6.1 enabled OK (python, jupyter-resource-usage)
        @pyviz/jupyterlab_pyviz v2.1.0 enabled OK (python, pyviz_comms)

I thought having the pyviz extension in the kernel environment was sufficient.

But the only way I could get rasterize=True to work in jupyterlab was to add the pyviz extension to the base environment (the one I launched jupyterlab from). I did this by installing panel into the base environment.

Does this all make sense or was there a better way to get this working?

@rsignell on my side this problem has disappeared, but it might be good for documentation (even if it’s just here in the forum) to provide a reproducible example in case someone else the same hiccup. Could you share your example, maybe we can both start from a completely “clean” setup. While I’m not a big fan of manual testing, sometimes it is useful