barbara costa
2011-Dec-12 10:10 UTC
[R] how to colour labels (each label with a colour) in a dendrogram?
Hello to all,
I still have this doubt.
I'd like to colour the different labels of my dendrogram each one with a
different colour. How can I do? I guess I could do using *edgetext* and
then *t.col* or* lab.col* but I don't know how to add edgetext to my
dendrogram. Can you help me please?
Example:
require(graphics); require(utils)
hc <- hclust(dist(USArrests), "ave")
(dend1 <- as.dendrogram(hc))
plot(dend1)
labels (USArrests) [[1]] # to know how many cities (labels) = 50
nP <- list(col=3:2, cex=c(2.0, 0.75), pch= 21:22,
bg= c("light blue", "pink"),
lab.cex = 0.75, lab.col = 1:50) # or use a palette:
palette(rainbow(50))
plot(dend1, edgePar=nP, dLeaf=1, edge.root = TRUE)
# this option is not correct. I want each of my labels (text) have a
different colour but that is not what is happening. How can I do that?
I'd appreciate your help.
thanks a lot again.
Barbara
On 9 December 2011 13:44, barbara costa <rbarbarahc@gmail.com> wrote:
> I'm sorry.
>
> (dend1 <- as.dendrogram(hc))
>
> On 9 December 2011 12:10, Sarah Goslee <sarah.goslee@gmail.com>
wrote:
>
>> Hi,
>>
>> On Fri, Dec 9, 2011 at 6:57 AM, barbara costa
<rbarbarahc@gmail.com>
>> wrote:
>> > Hello to all,
>> > I'd like to colour the different labels of my dendrogram. How
can I do?
>> I
>> > guess I could to using *edgetext* and then* t.col* or *lab.col*
but I
>> don't
>> > know how to add edgetext to my dendrogram. Can you help me please?
>> >
>> > Example:
>> >
>> > require(graphics); require(utils)
>> >
>> > hc <- hclust(dist(USArrests), "ave")
>> > plot(dend1)
>> > labels (USArrests) [[1]] # to know how many cities (labels) = 50
>>
>>
>> > require(graphics); require(utils)
>> >
>> > hc <- hclust(dist(USArrests), "ave")
>> > plot(dend1)
>> Error in plot(dend1) : object 'dend1' not found
>>
>> What's dend1?
>>
>> > nP <- list(col=3:2, cex=c(2.0, 0.75), pch= 21:22,
>> > bg= c("light blue", "pink"),
>> > lab.cex = 0.75, lab.col = 1:50) # or use a palette:
>> > palette(rainbow(50))
>> >
>> > plot(dend1, edgePar=nP, dLeaf=1, edge.root = TRUE)
>> >
>> > # this option is not correct. I want each of my labels (text) have
a
>> > different colour but that is not what is happening. How can I do
that?
>> >
>> > I'd appreciate your help.
>> > thanks a lot
>> > Barbara
>> >
>>
>>
>> --
>> Sarah Goslee
>> http://www.functionaldiversity.org
>>
>
>
[[alternative HTML version deleted]]
Sarah Goslee
2011-Dec-12 11:58 UTC
[R] how to colour labels (each label with a colour) in a dendrogram?
Did you try this: http://r.789695.n4.nabble.com/coloring-leaves-in-a-hclust-or-dendrogram-plot-td795496.html or this: http://bioinformatics.mdanderson.org/Software/OOMPA/ClassDiscovery/html/plotColoredClusters.html edgetext labels the segments, I think, and is not what I understand you to want, which is colors for the labels themselves. Thus, the above suggestions, which I found with about 30 seconds of Googling. Sarah On Mon, Dec 12, 2011 at 5:10 AM, barbara costa <rbarbarahc at gmail.com> wrote:> Hello to all, > I still have this doubt. > I'd like to colour the different labels of my dendrogram each one with a > different colour. How can I do? I guess I could do using edgetext and then > t.col or lab.col but I don't know how to add edgetext to my dendrogram. Can > you help me please? > > Example: > > require(graphics); require(utils) > hc <- hclust(dist(USArrests), "ave") > ?(dend1 <- as.dendrogram(hc)) > plot(dend1) > labels (USArrests) [[1]] # to know how many cities (labels) = 50 > > nP <- list(col=3:2, cex=c(2.0, 0.75), pch= 21:22, > ?????????? bg= c("light blue", "pink"), > ?????????? lab.cex = 0.75, lab.col = 1:50) # or use a palette: > palette(rainbow(50)) > > plot(dend1, edgePar=nP, dLeaf=1, edge.root = TRUE) > > # this option is not correct. I want each of my labels (text) have a > different colour but that is not what is happening. How can I do that? > > I'd appreciate your help. > thanks a lot again. > Barbara > > On 9 December 2011 13:44, barbara costa <rbarbarahc at gmail.com> wrote: >> >> I'm sorry. >> >> ?(dend1 <- as.dendrogram(hc)) >> >> On 9 December 2011 12:10, Sarah Goslee <sarah.goslee at gmail.com> wrote: >>> >>> Hi, >>> >>> On Fri, Dec 9, 2011 at 6:57 AM, barbara costa <rbarbarahc at gmail.com> >>> wrote: >>> > Hello to all, >>> > I'd like to colour the different labels of my dendrogram. How can I do? >>> > I >>> > guess I could to using *edgetext* and then* t.col* or *lab.col* but I >>> > don't >>> > know how to add edgetext to my dendrogram. Can you help me please? >>> > >>> > Example: >>> > >>> > require(graphics); require(utils) >>> > >>> > hc <- hclust(dist(USArrests), "ave") >>> > plot(dend1) >>> > labels (USArrests) [[1]] # to know how many cities (labels) = 50 >>> >>> >>> > require(graphics); require(utils) >>> > >>> > hc <- hclust(dist(USArrests), "ave") >>> > plot(dend1) >>> Error in plot(dend1) : object 'dend1' not found >>> >>> What's dend1? >>> >>> > nP <- list(col=3:2, cex=c(2.0, 0.75), pch= 21:22, >>> > ? ? ? ? ? bg= c("light blue", "pink"), >>> > ? ? ? ? ? lab.cex = 0.75, lab.col = 1:50) # or use a palette: >>> > palette(rainbow(50)) >>> > >>> > plot(dend1, edgePar=nP, dLeaf=1, edge.root = TRUE) >>> > >>> > # this option is not correct. I want each of my labels (text) have a >>> > different colour but that is not what is happening. How can I do that? >>> > >>> > I'd appreciate your help. >>> > thanks a lot >>> > Barbara >>> > >>> >>> >>> -- >>> Sarah Goslee >>> http://www.functionaldiversity.org >> >> >