简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM