Skip to content

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

Closed

Description

@apatange-source

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.

Activity

  1. apatange-source commented on Nov 23, 2021

    @apatange-source
    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.

  2. sheepshaker1011 commented on Dec 28, 2021

    @sheepshaker1011

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

  3. apatange-source commented on Dec 29, 2021

    @apatange-source
    Author

    @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), )

  4. sheepshaker1011 commented on Jan 7, 2022

    @sheepshaker1011

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions