Search code examples
rcolorsrgbtreemap

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.


Solution

  • 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"
    )