-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
feat: Add dendrogram #6511
base: main
Are you sure you want to change the base?
feat: Add dendrogram #6511
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6511 +/- ##
==========================================
+ Coverage 88.79% 88.83% +0.03%
==========================================
Files 323 323
Lines 68961 69181 +220
==========================================
+ Hits 61235 61454 +219
- Misses 7726 7727 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@hoxbro , is this ready for review? |
holoviews/operation/element.py
Outdated
|
||
adjoint_dims = param.List(item_type=str) # , bounds=(1, 2)) | ||
|
||
main_element = param.ClassSelector(default=HeatMap, class_=Dataset, instantiate=False, is_instance=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also expose some scipy setting for dendrogram and linkage here.
I think optimal_ordering
is a good start, ref.
xaxis=None, | ||
yaxis=None, | ||
show_grid=False, | ||
show_title=False, | ||
show_frame=False, | ||
border=0, | ||
default_tools=[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if a blank plot is the best default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably fine for now, and easy enough to restore
data[side_dim] = list(0.5 / data_adj.min() * data_adj) | ||
else: | ||
main_src = main.renderers[0].data_source.data | ||
data_adj, data_main = np.asarray(data[side_dim]), np.asarray(main_src.get(main_dim, main_src.get(f"{main_dim}s"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not great. Is there a better way to extract data_main
?
else: | ||
main = self.p.main_element(dataset.sort(sort_dims).reindex(element_kdims[:2]), vdims=vdims) | ||
|
||
for dim in map(str, main.kdims[::-1]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely, this is a bit sensitive to invert_axes
.
"source": [ | ||
"from holoviews.operation import dendrogram\n", | ||
"\n", | ||
"hv.operation.dendrogram(heatmap, adjoint_dims=[\"z\"], main_dim=\"y\")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can confirm, I see the same.
@@ -0,0 +1,108 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"In this example we will create a simple tree structure. While the default behavior for dendrograms is to hide axis labels, we will show them for this first example to make it easier to see the relationship between the input data and the output plot."
Reply via ReviewNB
@@ -0,0 +1,108 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,108 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"In this example we will create a simple tree structure. While the default behavior for dendrograms is to hide axis labels, we will show them for this first example to make it easier to see the relationship between the input data and the output plot."
Reply via ReviewNB
@@ -0,0 +1,108 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line #17. dendrogram = hv.Dendrogram(x, y)
dendrogram = hv.Dendrogram(x, y).opts(xaxis=True, yaxis=True)
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we saving hover support for a future PR?
return super().__new__(cls) | ||
|
||
def __init__(self, x, y=None, kdims=None, vdims=None, **params): | ||
data = x if y is None else zip(x, y) # strict=True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data = x if y is None else zip(x, y) # strict=True | |
if y is not None and len(x) != len(y): | |
raise ValueError("x and y must have the same length.") | |
data = x if y is None else zip(x, y) # strict=True when 3.9 is dropped |
Explicit strict enforcement for now?
xaxis=None, | ||
yaxis=None, | ||
show_grid=False, | ||
show_title=False, | ||
show_frame=False, | ||
border=0, | ||
default_tools=[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably fine for now, and easy enough to restore
resolves #6501
TODO:
Adjoint plot support responsive(will be done with: Improve responsive in adjoint layout for Bokeh backend #6527)hv.Curve([]) << hv.Path([(0, 0), (1, 1)]) << hv.Path([(0, 0), (200, 200)])
)Dendrogram(zip(...))
for creating the dataand plotlyScreencast.From.2025-02-24.17-41-32.mp4
Details