GithubHelp home page GithubHelp logo

Using custom color list about scipy-cluster HOT 2 CLOSED

deads avatar deads commented on July 20, 2024
Using custom color list

from scipy-cluster.

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
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 [email protected] on 25 Feb 2008 at 2:47

from scipy-cluster.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
(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 [email protected] on 25 Feb 2008 at 5:08

  • Changed state: Fixed

from scipy-cluster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.