holoviews
holoviews copied to clipboard
QuadMesh options dont propagate after rasterize is 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.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()
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()
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()
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()
A workaround is to apply the options outside the rasterize function.