Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Treemap specify the RGB colors in the treemap

I have the following but have been unsuccessful being able to specify the three RGB color codes I want to represent each part of the treemap.

Enter the data for tree map:

treedata <- data.frame(people = c("A","B", "C"), x = c(15,10,5))

Make our treemap:

FigA <-treemap(treedata,
        index="people",
        vSize="x",
        type="index",
        title=""
)

The three RBG colors I want for A, B, C respectively are #b5e3ff, #8f8eb1, #f6adca

I've been through all help but can't find someone specifying the color to the category using RGB.

like image 550
DocSoph Avatar asked Nov 19 '25 20:11

DocSoph


1 Answers

try this:

treedata <- data.frame(people = c("A","B", "C"), x = c(15,10,5),
    mycolors =  c("#b5e3ff", "#8f8eb1", "#f6adca") )

treemap(treedata,
    index="people",
    vSize="x",
    title="",
    type="color",
    vColor = "mycolors"
)
like image 176
servais Avatar answered Nov 22 '25 10:11

servais



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!