How do I omit labels in the R treemap?

前端 未结 2 925
感情败类
感情败类 2021-01-25 10:41

I\'ve been using the R treemap package and I have a treemap that\'s 2 levels deep. I want the second level labels to be printed but not the first.

Using the example in t

相关标签:
2条回答
  • 2021-01-25 11:27

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

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

    enter image description here

    0 讨论(0)
  • 2021-01-25 11:33

    Another option would consist in nullifying the size font 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))
    

    will only display the initial for the countries, not for the continents.

    0 讨论(0)
提交回复
热议问题