1717def create_dendrogram (X , orientation = "bottom" , labels = None ,
1818 colorscale = None , distfun = None ,
1919 linkagefun = lambda x : sch .linkage (x , 'complete' ),
20- hovertext = None ):
20+ hovertext = None , color_threshold = None ):
2121 """
2222 BETA function that returns a dendrogram Plotly figure object.
2323
@@ -28,10 +28,10 @@ def create_dendrogram(X, orientation="bottom", labels=None,
2828 :param (function) distfun: Function to compute the pairwise distance from
2929 the observations
3030 :param (function) linkagefun: Function to compute the linkage matrix from
31- the pairwise distances
31+ the pairwise distances
3232 :param (list[list]) hovertext: List of hovertext for constituent traces of dendrogram
33-
34- clusters
33+ clusters
34+ :param (double) color_threshold: Value at which the separation of clusters will be made
3535
3636 Example 1: Simple bottom oriented dendrogram
3737 ```
@@ -88,7 +88,7 @@ def create_dendrogram(X, orientation="bottom", labels=None,
8888
8989 dendrogram = _Dendrogram (X , orientation , labels , colorscale ,
9090 distfun = distfun , linkagefun = linkagefun ,
91- hovertext = hovertext )
91+ hovertext = hovertext , color_threshold = color_threshold )
9292
9393 return graph_objs .Figure (data = dendrogram .data ,
9494 layout = dendrogram .layout )
@@ -101,7 +101,7 @@ def __init__(self, X, orientation='bottom', labels=None, colorscale=None,
101101 width = np .inf , height = np .inf , xaxis = 'xaxis' , yaxis = 'yaxis' ,
102102 distfun = None ,
103103 linkagefun = lambda x : sch .linkage (x , 'complete' ),
104- hovertext = None ):
104+ hovertext = None , color_threshold = None ):
105105 self .orientation = orientation
106106 self .labels = labels
107107 self .xaxis = xaxis
@@ -128,7 +128,8 @@ def __init__(self, X, orientation='bottom', labels=None, colorscale=None,
128128 ordered_labels , leaves ) = self .get_dendrogram_traces (X , colorscale ,
129129 distfun ,
130130 linkagefun ,
131- hovertext )
131+ hovertext ,
132+ color_threshold )
132133
133134 self .labels = ordered_labels
134135 self .leaves = leaves
@@ -249,7 +250,7 @@ def set_figure_layout(self, width, height):
249250
250251 return self .layout
251252
252- def get_dendrogram_traces (self , X , colorscale , distfun , linkagefun , hovertext ):
253+ def get_dendrogram_traces (self , X , colorscale , distfun , linkagefun , hovertext , color_threshold ):
253254 """
254255 Calculates all the elements needed for plotting a dendrogram.
255256
@@ -274,7 +275,8 @@ def get_dendrogram_traces(self, X, colorscale, distfun, linkagefun, hovertext):
274275 d = distfun (X )
275276 Z = linkagefun (d )
276277 P = sch .dendrogram (Z , orientation = self .orientation ,
277- labels = self .labels , no_plot = True )
278+ labels = self .labels , no_plot = True ,
279+ color_threshold = color_threshold )
278280
279281 icoord = scp .array (P ['icoord' ])
280282 dcoord = scp .array (P ['dcoord' ])
0 commit comments