[SciPy-User] Color Lists in Dendrograms / Hierarchical Clustering

Daniel Miner danielcarlminer@gmail....
Tue Jul 16 04:45:17 CDT 2013

```Hi everyone,

I'm trying to use hierarchical clustering to tease out some structure in
data that I already know exists as a sort of test case to (hopefully) show
that it can be reliably done for the type of data I'm concerned with. To
this end, knowing that the full call for dendrogram generation is:

scipy.cluster.hioerarchy.dendrogram(Z, p=30, truncate_mode=None,
color_threshold=None, get_leaves=True, orientation='top',labels=None,
count_sort=False, distance_sort=False, show_leaf_counts=True,
no_plot=False, no_labels=False, color_list=None,leaf_font_size=None,
leaf_rotation=None, leaf_label_func=None, no_leaves=False,

I use one of the linkage algorithms to generate the linkage, manually
create a list of colors "c_list" as a list with a color corresponding to
each known category of original data for each data point - i.e. if I have
data [1,2,3] and know that 1 and 2 come from the same category but 3 is
different, I make a list ['r','r','g'] - and try to use it as follows:

import matplotlib.pyplot as pt
import scipy.cluster.hierarchy as sc
[import other stuff]
[load data DAT, generate color list]
lw = sc.ward(DAT)
dw = sc.dendrogram(lw,color_list='c_list')
pt.show()

However, the colors seem to do nothing. I've tried listing them both
numerically (i.e. [1,2,3]) and as characters (i.e. ['r','g','b']), and have
tried making the call with c_list in single quotes as shown and with no
quotes at all. There is no documentation at
http://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.dendrogram.htmlregarding
an expected format for the color list, and without this color
labeling, I can't check to see if the clustering is doing what I hope it
does, as there are many data points and it would be prohibitively difficult
to read though each of the tiny index labels at the bottom of the default
dendrogram plot. I really have no idea how to proceed in order to make this
work and am hoping that someone here can provide some advice. Thanks.

Best regards,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20130716/3b97f6e4/attachment.html
```