Adding to this discussion. I was trying to embed this into a dashboard. This is the working code:
ds = xr.tutorial.open_dataset('air_temperature')
#create a new variable to have something to change
ds['air_C'] = ds['air']-273
class GliderParams(param.Parameterized):
'''Class containing the methods for dataset and variable selection'''
surface_var = param.Selector(['air','air_C'], default = 'air', label = 'Surface Field')
#@param.depends('surface_var')
def imaging(surface_var):
image,select = ds[surface_var].hvplot(groupby='time',widget_location = 'bottom',
cmap='RdBu_r',ylim=[15,80],xlim = [200,360],
crs=ccrs.PlateCarree(),projection=ccrs.PlateCarree())
#coastline=True,
stream = hv.streams.Tap(source=image.object, x=0, y=0)
timeseries = ds[surface_var].interactive.sel(lon=stream.param.x, lat=stream.param.y, method='nearest').hvplot('time')
return pn.Column(image, select,timeseries.dmap())
gp = GliderParams()
pn.Row(pn.Param(gp, name=''),pn.bind(imaging,gp.param.surface_var))
However, when adding coastline=True
, I get an empty plot (not sure why).
The second problem I’m encountering is how to add a dynamic title to the timeseries plot to incorporate the clicked lat/lon?
Thank you!