holoviews icon indicating copy to clipboard operation
holoviews copied to clipboard

QuadMesh options dont propagate after rasterize is applied

Open benbarn313 opened this issue 7 months ago • 0 comments

import holoviews as hv
from holoviews.operation.datashader import rasterize
import panel as pn
import xarray as xr

pn.extension()

ds = xr.tutorial.open_dataset("air_temperature")

def create_plot(ds):
    plot = hv.QuadMesh(ds.isel(time=0), ['lon', 'lat'])
    return plot.opts(colorbar = True, backend_opts={"cbar.title": "title"}, cmap = 'greens')

plot = rasterize(hv.DynamicMap(pn.bind(create_plot, ds)))
pn.Row(plot).servable()

image

I have applied a colormap and colorbar in the options here, and they aren't applied to the output image as shown.

import holoviews as hv
from holoviews.operation.datashader import rasterize
import panel as pn
import xarray as xr

pn.extension()

ds = xr.tutorial.open_dataset("air_temperature")

def create_plot(ds):
    plot = hv.QuadMesh(ds.isel(time=0), ['lon', 'lat'])
    return plot.opts(colorbar = True, backend_opts={"cbar.title": "title"}, cmap = 'greens')

plot = hv.DynamicMap(pn.bind(create_plot, ds))
pn.Row(plot).servable()

image

Here's the same example, but without the rasterize function. You can see the options are applied.

import holoviews as hv
from holoviews.operation.datashader import rasterize
import panel as pn
import xarray as xr

pn.extension()

ds = xr.tutorial.open_dataset("air_temperature")

def create_plot(ds):
    plot = hv.Image(ds.isel(time=0), ['lon', 'lat'])
    return plot.opts(colorbar = True, backend_opts={"cbar.title": "title"}, cmap = 'greens')

plot = rasterize(hv.DynamicMap(pn.bind(create_plot, ds)))
pn.Row(plot).servable()

image

Here you can see that this is not a problem for hv.Image.

import holoviews as hv
from holoviews.operation.datashader import rasterize
import panel as pn
import xarray as xr

pn.extension()

ds = xr.tutorial.open_dataset("air_temperature")

def create_plot(ds):
    plot = hv.QuadMesh(ds.isel(time=0), ['lon', 'lat'])
    return plot

plot = rasterize(hv.DynamicMap(pn.bind(create_plot, ds))).opts(colorbar = True, backend_opts={"cbar.title": "title"}, cmap = 'greens')
pn.Row(plot).servable()

image

A workaround is to apply the options outside the rasterize function.

benbarn313 avatar Nov 15 '23 15:11 benbarn313