How to skip shortcuts in R treemap?

I used the R treemap package , and I have a treemap that is on 2 levels. I want second-level labels printed, but not the first.

Using the example on the manual page:

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

example map card http://www.eecs.tufts.edu/~rveroy/stuff/GNI2010-treemap.png

I want to get rid of the labels of the continents, but keep the iso3 labels. I apologize in advance if it is in the documents, but did not find it.

+1
source share
2 answers

To remove the labels of the continents, you can publish hoc to edit the graph. The graph creates a grid object. The last two elements of this grid object appear as country labels. Therefore, you can remove them as follows:

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

enter image description here

+4
source

Another option is to reduce the font size that the fonts you want to see disappear. For instance,

 tmPlot(GNI2010, index=c("continent", "iso3"), vSize="population", vColor="GNI", type="value", fontsize.labels=c(0,10)) 

only the initial value will be displayed for countries, not for continents.

+3
source

Source: https://habr.com/ru/post/1234988/


All Articles