Message Boards Message Boards

1
|
1877 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

How to change color of branches in Dendrogram?

Posted 2 years ago

Hi, It appears the default color for branches in a Dendrogram is gray. I tried changing them to Black with BaseStyle->Black to no avail. How is this accomplished?

enter image description here

POSTED BY: Richard Frost
Posted 2 years ago

I haven't used Dendrograms before, so I just started experimenting. If you look at Dendrogram[{1, 2, 4}] // FullForm, you can see that it's a Graphics object. That's not what I expected, since Graph and Tree and so forth keep an abstract representation and just display as if they were graphics. On the other hand, it means we can use the same options that Graphics uses. But, I don't know what option affects line color (I always just insert the colors among the graphics primitives). However, since it's a Graphics object, we can manipulate it directly. If you go back and look at the FullForm, you can see that it's just a set of Lines and that their color is set to GrayLevel[0.65]. We could just replace that:

ReplacePart[Dendrogram[{1, 2, 4}], {1, 1, 1} -> Splice[{Dashed, Red}]]

This seems a bit of a hack, but it could be rolled into a function so that you could use it automatically.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract