Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using custom color list #2

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 2 comments
Closed

Using custom color list #2

GoogleCodeExporter opened this issue Mar 19, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. R = dendrogram(Z, color_list=['brown' for i in range(0,150)])
2. All edges in dendrogram are just green

Solution ('hack'):
Line: 2474
if color_list is None:
    color_list=[]

Colors are still added within the program, but custom colors are used
first. Maybe there is a better solution for this




Original issue reported on code.google.com by mdeholla...@gmail.com on 18 Feb 2008 at 1:49

@GoogleCodeExporter
Copy link
Author

The behavior of the link coloring is very similar to MATLAB's behavior, which 
is what
I intended. Are you trying to specify the color for each link? Just to be clear 
--
that's not the expected behavior of the link coloring code in hcluster. The 
feature
could be added to do that if you want to do that. Is that what you're trying to 
do?

I don't know if you looked at the colorthreshold parameter documentation:

      Colors all the descendent links below a cluster node k the same color
      if k is the first node below the cut threshold t. All links connecting
      nodes with distances greater than or equal to the threshold are
      colored blue. If t is less than or equal to zero, all nodes
      are colored blue. If t is None or 'default', corresponding with
      MATLAB(TM) behavior, the threshold is set to 0.7*max(Z[:,2]).

If you *do* intend to have this behavior, but you just want to use different 
colors,
use the set_link_color_palette feature, which I've just added.

Thanks a bunch!

Damian Eads

Original comment by damian.e...@gmail.com on 25 Feb 2008 at 2:47

@GoogleCodeExporter
Copy link
Author

(reposted from personal e-mail message to issue creator)

When I designed scipy-cluster (hcluster), I wasn't expecting the user to mess 
with
the color_list variable. Given my busy schedule, I put less priority on 
commenting
the private functions whose names are usually prefixed with an underscore.

You'll see several lists two sets of lists being appended 
_dendrogram_calculate_info,
which calculates the coordinates and attributes of the shapes to plot in the 
plotting
window. One set corresponds to leaf-node clusters (singletons and truncated
non-singletons) and the other, non-singleton clusters.

 leaf clusters: ivl
 non-singleton clusters: icoord_list, dcoord_list, color_list,

The order of the color_list elements represents the order links are painted in 
the
plot, not the order clusters are joined. The reason why the orders don't 
correspond
to one another is dendrogram supports options for changing the way the 
hierarchy is
plotted (see count_sort and distance_sort for examples).

I added a link_color_func parameter to the dendrogram function you can use to 
set the
color of a links. This is a better solution than mucking with the color_list 
data
structure because the order does not correspond to anything that would be 
intuitive
to the user--just the order in which shapes are painted to the window.

Here's the help documentation for it:

   R = dendrogram(..., link_color_func)

       When a link is painted, the function link_color_function is
       called with the non-singleton id. The function is
       expected to returns a matplotlib color string representing
       the color to paint the link.

       For example:

         dendrogram(Z, link_color_func=lambda k: colors[k])

       colors the links of every untruncated non-singleton node k
       with colors[k].

This feature appears in the 0.1.4 release. Let me know if this helps.

Damian

Original comment by damian.e...@gmail.com on 25 Feb 2008 at 5:08

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant