R Tree-maps - make background label transparent

I am trying to create a treemap using R package treemap

. Here is the code (this is a sample from the package)

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

      

The problem I ran into was the color of the labels. When I only have 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 indices, the label changes color. I just want all labels to be transparent. Is it possible?

enter image description here

+3


source to share


2 answers


As I wrote this, I found the solution in the documentation: you just need to add the option bg.lables = 0

. Its range is from 0 to 255, the default is 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 colors. But at least the label can be transparent.

+1


source


Possible duplicate :

To remove continent labels, you can post hoc edit the graph. The graph creates a grid object. The last two elements of this grid object appear to be country labels. Hence, you can remove them like this:



lapply(tail(grid.ls(print=FALSE)$name, 2), grid.remove)

      

0


source







All Articles