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 adding annotator indicator view but not edit to certain plots #127

Open
droumis opened this issue Jul 23, 2024 · 0 comments
Open

Comments

@droumis
Copy link
Member

droumis commented Jul 23, 2024

For certain accessory plots that only share partial kdims with the annotator, we should find a way (aside from just disabling the toolbar entirely) to display annotations without allowing for them to be editable on these plots, which errors because obviously one of the kdims remains is unspecified.

For instance, in the following, we would want to disable annotator box creation on the side and top plots, but still have the annotations visible on them.

Code
import numpy as np
import xarray as xr

width = 6
height = 5
frames = 30

data = np.random.random((height, width)) + np.repeat([1, 0.5], width//2)[None, :]
data = np.transpose(np.array([data * (0.95 ** i) for i in range(frames)]), (2, 1, 0))

data_array = xr.DataArray(
    data,
    dims=["width","height", "frame"],
    coords={
        "width": np.arange(width),
        "height": np.arange(height),
        "frame": np.arange(frames),
    },
    name="data"
)

import holoviews as hv; hv.extension('bokeh')
import panel as pn; pn.extension('tabulator')

main = hv.Image(data_array.sel(frame=10)).opts(width=500, height=400)
right = hv.Image(data_array.mean('width'), ['frame', 'height']).opts(width=200, height=400)
top = hv.Image(data_array.mean('height'), ['width', 'frame']).opts(width=500, height=200)

# pn.Column(top, pn.Row(main,right))

from holonote.annotate import Annotator
from holonote.app import PanelWidgets
from holonote.app.tabulator import AnnotatorTable

annotator = Annotator({"height": float, "width": float}, fields=["type"], groupby="type")
color_dim = hv.dim("type").categorize(
    categories={"A": "red", "B": "orange"}, default="grey"
)
annotator.style.color = color_dim
annotator.style.alpha=.6
panel_widgets = PanelWidgets(annotator)
table_widget = AnnotatorTable(annotator)
annotator_widgets = pn.WidgetBox(panel_widgets, table_widget, horizontal=True)

pn.Column(annotator_widgets, (top * annotator).opts(toolbar='disable'), pn.Row(main * annotator, right * annotator))
GMT20240723-224422_Clip_Demetris.Roumis.s.Clip.07_23_2024.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant