holoviz / holoviz/hvplot

Limitations of the .interactive API

Open
#531 3 comments 1 reaction 1 assignee Claimed by @philippjfr View on GitHub
api: interactive
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

The new .interactive API is really fun to work with, but I'm bumping up against either its limits or my own imagination. E.g. if I start with this example that works well:

```python
import panel as pn, xarray as xr, holoviews as hv, hvplot.xarray
pn.extension()

ds = xr.tutorial.open_dataset('air_temperature')
image = ds.hvplot('lon', 'lat')
stream = hv.streams.Tap(source=image, x=-88+360, y=40)
timeseries = ds.interactive.sel(lon=stream.param.x, lat=stream.param.y,
method="nearest").hvplot('time')

pn.Column(image, timeseries.dmap())
```
![image](https://user-images.githubusercontent.com/1695496/101222225-f6268280-364e-11eb-8e72-feb9926c5501.png)

That's great, but then I want to put some indication of where I tapped, as a red dot in the first plot and as numeric values in the second plot. I can't quite see how to do it. A start, with nothing actually connected:

```python
import panel as pn, xarray as xr, holoviews as hv, hvplot.xarray
pn.extension()

ds = xr.tutorial.open_dataset('air_temperature')
image = ds.hvplot('lon', 'lat')
stream = hv.streams.Tap(source=image, x=-88+360, y=40)
point = hv.Points([(260,40)]).opts(size=5, color="red")
timeseries = ds.interactive.sel(lon=stream.param.x, lat=stream.param.y,
method="nearest").hvplot('time').relabel(f"lon: {stream.x}, lat: {stream.y}")

pn.Column(image*point, timeseries.dmap())
```
![image](https://user-images.githubusercontent.com/1695496/101222653-d479cb00-364f-11eb-8646-75d10ef95d72.png)

I could write a DynamicMap returning a Points object, but that's an entirely new concept, so I'm wondering whether there is some .apply or other more reactive approach that fits better with the rest of the code here, i.e. without an explicit callback.

Also not sure how to specify the title properly in the second plot; stream.param.x won't work, as it just shows the Parameter object itself rather than fetching the current value. Is there a clean way?

It also might be nice to have an automatic way of getting the default title for the second plot, via hvPlot and .interactive somehow connecting up widget values to the title the same way NdOverlays do, but I guess that would be a separate issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.