Skip to content

scipy.cluster.hierarchy.linkage not working with plotly.figure_factory.create_dendrogram() [LABELS] #3485

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

Closed
apatange-source opened this issue Nov 23, 2021 · 4 comments

Comments

@apatange-source
Copy link

apatange-source commented Nov 23, 2021

I'm trying to plot a dendrogram using scipy's hierarchy clustering.

When I try to add the dataframe columns as the labels for the create_dendrogram() function,
image

Is there any way for me to make it work?

It works well with scipy's inbuilt dendrogram() function.

@apatange-source
Copy link
Author

Also there is a difference between the plolty dendrogram and the scipy dendrogram when I try to plot the plotly one without the label
Screenshot from 2021-11-23 15-48-27
s.

@sheepshaker1011
Copy link

@apatange-source I met the same problem, how did you fix it?

@apatange-source
Copy link
Author

apatange-source commented Dec 29, 2021

@apatange-source I met the same problem, how did you fix it?

Try using this:
x = np.transpose(df.astype(float))

fig = ff.create_dendrogram( X=x, labels=df.columns.to_list(), linkagefun=lambda x: hierarchy.linkage(x, method), )

@sheepshaker1011
Copy link

@apatange-source I met the same problem, how did you fix it?

Try using this: x = np.transpose(df.astype(float))

fig = ff.create_dendrogram( X=x, labels=df.columns.to_list(), linkagefun=lambda x: hierarchy.linkage(x, method), )

Thanks!

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

2 participants