Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Tree-maps - make label background transparent

Tags:

r

treemap

I'm trying to create a treemap using R package treemap. Here is the code (it's a sample from the package)

library(treemap)
data(GNI2010)
treemap(GNI2010,
        index=c("continent", "iso3"),
        vSize="population",
        vColor="GNI",
        type="value")

The issue I'm having is with the colour of the labels. When I have just one index, then the output is ok:

library(treemap)
    data(GNI2010)
    treemap(GNI2010,
            index=c("iso3"), #single index
            vSize="population",
            vColor="GNI",
            type="value")

enter image description here

But when I have multiple indexes, then the label changes colour. I just want all labels to be transparent. Is that possible?

enter image description here

like image 418
jmich738 Avatar asked Aug 31 '25 18:08

jmich738


1 Answers

Just as I wrote this I found the solution in the documentation: you just need to add the option bg.lables = 0. Its a range from 0-255, by default its 220.

library(treemap)
data(GNI2010)
treemap(GNI2010,
        index=c("continent", "iso3"),
        vSize="population",
        vColor="GNI",
        type="value",
        bg.labels = 0)

enter image description here

There are other options in the package to let you play with colours. But at least the label can be transparent.

like image 188
jmich738 Avatar answered Sep 02 '25 11:09

jmich738