17
17
def create_dendrogram (X , orientation = "bottom" , labels = None ,
18
18
colorscale = None , distfun = None ,
19
19
linkagefun = lambda x : sch .linkage (x , 'complete' ),
20
- annotation = None ):
20
+ hovertext = None ):
21
21
"""
22
22
BETA function that returns a dendrogram Plotly figure object.
23
23
@@ -29,6 +29,7 @@ def create_dendrogram(X, orientation="bottom", labels=None,
29
29
the observations
30
30
:param (function) linkagefun: Function to compute the linkage matrix from
31
31
the pairwise distances
32
+ :param (list[list]) hovertext: List of hovertext for constituent traces of dendrogram
32
33
33
34
clusters
34
35
@@ -87,7 +88,7 @@ def create_dendrogram(X, orientation="bottom", labels=None,
87
88
88
89
dendrogram = _Dendrogram (X , orientation , labels , colorscale ,
89
90
distfun = distfun , linkagefun = linkagefun ,
90
- annotation = annotation )
91
+ hovertext = hovertext )
91
92
92
93
return {'layout' : dendrogram .layout ,
93
94
'data' : dendrogram .data }
@@ -100,7 +101,7 @@ def __init__(self, X, orientation='bottom', labels=None, colorscale=None,
100
101
width = "100%" , height = "100%" , xaxis = 'xaxis' , yaxis = 'yaxis' ,
101
102
distfun = None ,
102
103
linkagefun = lambda x : sch .linkage (x , 'complete' ),
103
- annotation = None ):
104
+ hovertext = None ):
104
105
self .orientation = orientation
105
106
self .labels = labels
106
107
self .xaxis = xaxis
@@ -127,7 +128,7 @@ def __init__(self, X, orientation='bottom', labels=None, colorscale=None,
127
128
ordered_labels , leaves ) = self .get_dendrogram_traces (X , colorscale ,
128
129
distfun ,
129
130
linkagefun ,
130
- annotation )
131
+ hovertext )
131
132
132
133
self .labels = ordered_labels
133
134
self .leaves = leaves
@@ -236,7 +237,7 @@ def set_figure_layout(self, width, height):
236
237
237
238
return self .layout
238
239
239
- def get_dendrogram_traces (self , X , colorscale , distfun , linkagefun , annotation ):
240
+ def get_dendrogram_traces (self , X , colorscale , distfun , linkagefun , hovertext ):
240
241
"""
241
242
Calculates all the elements needed for plotting a dendrogram.
242
243
@@ -246,6 +247,7 @@ def get_dendrogram_traces(self, X, colorscale, distfun, linkagefun, annotation):
246
247
from the observations
247
248
:param (function) linkagefun: Function to compute the linkage matrix
248
249
from the pairwise distances
250
+ :param (list) hovertext: List of hovertext for constituent traces of dendrogram
249
251
:rtype (tuple): Contains all the traces in the following order:
250
252
(a) trace_list: List of Plotly trace objects for dendrogram tree
251
253
(b) icoord: All X points of the dendrogram tree as array of arrays
@@ -283,15 +285,15 @@ def get_dendrogram_traces(self, X, colorscale, distfun, linkagefun, annotation):
283
285
else :
284
286
ys = icoord [i ]
285
287
color_key = color_list [i ]
286
- text_annotation = None
287
- if annotation :
288
- text_annotation = annotation [i ]
288
+ hovertext_label = None
289
+ if hovertext :
290
+ hovertext_label = hovertext [i ]
289
291
trace = graph_objs .Scatter (
290
292
x = np .multiply (self .sign [self .xaxis ], xs ),
291
293
y = np .multiply (self .sign [self .yaxis ], ys ),
292
294
mode = 'lines' ,
293
295
marker = graph_objs .Marker (color = colors [color_key ]),
294
- text = text_annotation ,
296
+ text = hovertext_label ,
295
297
hoverinfo = 'text'
296
298
)
297
299
0 commit comments