Skip to content

Commit 58a6f95

Browse files
Updated documentation for colorscale of create_dendrogram
1 parent 90e417d commit 58a6f95

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

Diff for: packages/python/plotly/plotly/figure_factory/_dendrogram.py

+10-24
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,22 @@ def create_dendrogram(
2525
color_threshold=None,
2626
):
2727
"""
28-
Function that returns a dendrogram Plotly figure object.
28+
Function that returns a dendrogram Plotly figure object. This is a thin
29+
wrapper around scipy.cluster.hierarchy.dendrogram.
2930
3031
See also https://dash.plot.ly/dash-bio/clustergram.
3132
3233
:param (ndarray) X: Matrix of observations as array of arrays
3334
:param (str) orientation: 'top', 'right', 'bottom', or 'left'
3435
:param (list) labels: List of axis category labels(observation labels)
35-
:param (list) colorscale: Optional colorscale for dendrogram tree. To
36-
totally replace the default colorscale, a custom
37-
colorscale must contain 8 colors, corresponding
38-
to when the underlying
39-
scipy.cluster.hierarchy.dendrogram specifies
40-
'b', 'c', 'g', 'k', 'm', 'r', 'w', 'y', in that
41-
order. So if you want 'b', 'c', 'g', 'k', to map
42-
to rgb(255,0,0) and 'm', 'r', 'w', 'y', to map
43-
to rgb(0,255,0), the colorscale should be
44-
['rgb(255,0,0)','rgb(255,0,0)','rgb(255,0,0)',
45-
'rgb(255,0,0)','rgb(0,255,0)','rgb(0,255,0)',
46-
'rgb(0,255,0)','rgb(0,255,0)',] If using
47-
scipy >= 1.5.1, instead of the letters above, the
48-
colors are specfied as 'C0', 'C1', etc. and in
49-
that case the list corresponds to the colors:
50-
'C0', 'C3' or 'C9', 'C1' or 'C7', 'C6', 'C2',
51-
'C4', 'C8',<ignored>, 'C5', 'C7', e.g., if
52-
scipy.cluster.hierarchy.dendrogram uses the color
53-
'C3' or 'C9' this is mapped to the rgb value in
54-
index 1, and there is not color that maps to index
55-
7, of the colorscale. If the colorscale has less
56-
than 8 colors, the remaining colors remain the
57-
default.
36+
:param (list) colorscale: Optional colorscale for the dendrogram tree. With
37+
scipy<=1.4.1 requires 8 colors to be specified,
38+
the 7th of which is ignored. With scipy>=1.5.0,
39+
requires 10 colors. In this case the 8th color is
40+
ignored and the 2nd, 3rd and 6th are used twice as
41+
often as the others. Given a shorter list, the
42+
missing values are replaced with defaults and with
43+
a longer list the extra values are ignored.
5844
:param (function) distfun: Function to compute the pairwise distance from
5945
the observations
6046
:param (function) linkagefun: Function to compute the linkage matrix from

0 commit comments

Comments
 (0)