Skip to content
Advertisement

How to draw colored rectangles around grouped clusters in dendogram?

I try to add colored rectangle to dendrogram results like as follow:

Text

this is my dendrogram codes:

JavaScript

However, this is only add colorful line not a rectangle like in the above image. How can I create image like this?

Thanks

Advertisement

Answer

You can loop through the generated path collections and draw a bounding box.

Optionally, you could set the height to the color_threshold= parameter, which defaults to Z[:, 2].max() * 0.7.

The last collection is are the unclassified lines, so the example code below loops through all earlier collections.

JavaScript

example dendogram

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement