如何省略 R 树图中的标签? [英] How do I omit labels in the R treemap?

查看:50
本文介绍了如何省略 R 树图中的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 R 树图包我有一个 2 层深的树状图.我想要打印第二级标签而不是第一级标签.

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.

使用手册页中的示例:

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

树形图示例 http://www.eecs.tufts.edu/~rveroy/stuff/GNI2010-treemap.png

我想去掉大陆标签,但保留iso3标签.如果文件中有但没有找到,我提前道歉.

I want to get rid of the continent labels, but retain the iso3 labels. I apologize in advance if it is in the documents but haven't found it.

推荐答案

要删除大洲标签,您可以事后编辑图表.该图生成一个网格对象.此网格对象的最后两个元素似乎是国家/地区标签.因此,您可以通过这种方式删除它们:

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)

这篇关于如何省略 R 树图中的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆