Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Tap stream for multi_y #6359

Closed
droumis opened this issue Aug 12, 2024 · 2 comments · Fixed by #6374
Closed

Support Tap stream for multi_y #6359

droumis opened this issue Aug 12, 2024 · 2 comments · Fixed by #6374
Assignees
Labels
TRIAGE Needs triaging

Comments

@droumis
Copy link
Member

droumis commented Aug 12, 2024

Is your feature request related to a problem? Please describe.

Currently, the Y values returned from a tap stream are only from one of the Y axes on an overlay plot with multi_y enabled.

Describe the solution you'd like

In such a case, we need a Tap stream to return all Y values. Perhaps as a dict, mapping from the name of each y-dim to the tapped y-coordinate.

Describe alternatives you've considered

Alternative might be to have a multi_y tap callback specify y, y2, ... as input args.. but I think this would get confusing as it's not so clear which axis is primary when just using multi_y=True.

Additional context

Simple example of multi_y only returning one y val on tap:

Code
import numpy as np
import pandas as pd
import holoviews as hv
from holoviews.streams import Tap
import panel as pn

hv.extension('bokeh')
pn.extension('tabulator')

np.random.seed(42)
x = np.linspace(0, 10, 100)
y1 = np.sin(x) + np.random.normal(0, 0.1, 100)
y2 = np.cos(x) + np.random.normal(0, 0.1, 100) * 100
df1 = pd.DataFrame({'x': x, 'y1': y1, 'axis': 'y1'})
df2 = pd.DataFrame({'x': x, 'y2': y2, 'axis': 'y2'})

curve1 = hv.Curve(df1, kdims='x', vdims=['y1', 'axis']).opts(color='red')
curve2 = hv.Curve(df2, kdims='x', vdims=['y2', 'axis']).opts(color='blue')

overlay = (curve1 * curve2).opts(multi_y=True, width=600)

def inspect(x, y):
    if y is None:
        return(hv.Curve([]) * hv.Curve([]))
    return hv.Curve([]) * hv.Text(x=.5, y=.5, text=f'x: {x:.2f}, y: {y:.2f}')

inspect_output = hv.DynamicMap(inspect, streams=[Tap(source=overlay)]).opts(width=600)

pn.Row((overlay + inspect_output).cols(1).opts(shared_axes=False)).servable()
GMT20240812-173722_Clip_Multiy_tap.mp4
@droumis droumis added the TRIAGE Needs triaging label Aug 12, 2024
@droumis
Copy link
Member Author

droumis commented Aug 12, 2024

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
TRIAGE Needs triaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants