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

Conditionally invert axis to align annotations with elements #113

Merged
merged 4 commits into from
Jun 26, 2024

Conversation

droumis
Copy link
Member

@droumis droumis commented Jun 26, 2024

Fixes #112

Invert axis if the first kdim of the element is not an annotator kdim, ensuring overlaying annotations align with underlying elements.

Code
import holoviews as hv; hv.extension('bokeh')
import panel as pn; pn.extension()
import numpy as np

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

annotator = Annotator({"x": float, "y": float}, fields=["description"])
bounds = (-1, -1, 1, 1)
data = np.array([[0, 1], [1, 0]])
img = hv.Image(data, kdims=['x', 'y'], bounds=bounds)
img_right = hv.Image(data, kdims=['z', 'y'], bounds=bounds)  # y as second kdim! so HSpan

left_plot = annotator * img
right_plot = annotator * img_right
layout = left_plot + right_plot

annotator.set_regions(x=(-0.15, 0.15), y=(-0.25, 0.25))
annotator.add_annotation(description="Test")

layout

image

@droumis
Copy link
Member Author

droumis commented Jun 26, 2024

Thanks to @hoxbro for the assist!

Copy link

codecov bot commented Jun 26, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link

codspeed-hq bot commented Jun 26, 2024

CodSpeed Performance Report

Merging #113 will not alter performance

Comparing invert_axis (2dddc30) with main (c79d4f0)

Summary

✅ 6 untouched benchmarks

@hoxbro hoxbro merged commit 2c67868 into main Jun 26, 2024
13 checks passed
@hoxbro hoxbro deleted the invert_axis branch June 26, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Annotation applies to wrong axis when matching axis is not 'x' (vspan)
2 participants