holoviz / holonote

Tools to create, edit, and persist annotated regions for HoloViews
https://holonote.holoviz.org
BSD 3-Clause "New" or "Revised" License
21 stars 2 forks source link

Support adding annotator indicator view but not edit to certain plots #127

Open droumis opened 1 month ago

droumis commented 1 month ago

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 ```python 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)) ```

https://github.com/user-attachments/assets/a3d70e25-8d12-467e-a349-23064ad89737