Open In App

plotly.figure_factory.create_dendrogram() function in Python

Last Updated : 26 Jul, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

Plotly library of Python can be very useful for data visualization and understanding the data simply and easily.

plotly.figure_factory.create_dendrogram

 A dendrogram is a diagram representing a tree. The figure factory called create_dendrogram performs hierarchical clustering on data and represents the resulting tree. Values on the tree depth axis correspond to distances between clusters.

Syntax: plotly.figure_factory.create_dendrogram(X, orientation='bottom', labels=None, colorscale=None, distfun=None, linkagefun=<function <lambda>>, hovertext=None, color_threshold=None)

Parameter:

X ((ndarray)) – it describes the matrix of observations as array of arrays

orientation ((str)) – in this we use ‘top’, ‘right’, ‘bottom’, or ‘left’

labels ((list)) – it describes the list of axis category labels(observation labels)

colorscale ((list)) – it describes the optional colorscale for dendrogram tree

distfun ((function)) – it describes the function to compute the pairwise distance from the observations

linkagefun ((function)) – it describes the function to compute the linkage matrix from the pairwise distances

hovertext ((list[list])) – it describes the list of hovertext for constituent traces of dendrogram clusters

color_threshold ((double)) – it describes the value at which the separation of clusters will be made

Example 1: Simple bottom oriented dendrogram

Python3
from plotly.figure_factory import create_dendrogram
import numpy as np


X = np.random.rand(10,10)
fig = create_dendrogram(X)
fig.show()

Output:

Example 2:  Dendrogram to put on the left of the heatmap

Python3
from plotly.figure_factory import create_dendrogram
import numpy as np


X = np.random.rand(5,5)
names = ['Jack', 'Oxana', 'John', 'Chelsea', 'Mark']

dendro = create_dendrogram(X, orientation='right', labels=names)
dendro.update_layout({'width':700, 'height':500}) 
dendro.show()

Output:


Article Tags :
Practice Tags :

Similar Reads

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy