首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何阅读ggraph径向图中的文本标签

如何阅读ggraph径向图中的文本标签
EN

Stack Overflow用户
提问于 2017-04-01 12:58:38
回答 1查看 566关注 0票数 4

ggraph中,如果打印是径向的,则无论是否使用repel=T,标签都可能变得拥挤。

有没有一种方法可以使标签具有交互性,或者允许旋转图形以读取标签?

代码语言:javascript
复制
library(ggraph)
mtcarsDen <- as.dendrogram(hclust(dist(mtcars[1:4],  method='euclidean'), 
                            method='ward.D2'))
ggraph(graph = mtcarsDen, layout = 'dendrogram', repel = TRUE, circular = TRUE, 
   ratio = 0.5) + 
geom_edge_elbow() + 
geom_node_text(aes(x = x*1.05, y=y*1.05, filter=leaf, 
                 angle = node_angle(x, y), label = label), 
             size=3, hjust='outward') + 
geom_node_point(aes(filter=leaf)) + 
coord_fixed() + 
ggforce::theme_no_axes()
EN

回答 1

Stack Overflow用户

发布于 2017-08-23 15:15:15

你可以像这样修改你的角度美学:

代码语言:javascript
复制
ggraph(graph = mtcarsDen, layout = 'dendrogram', repel = TRUE, circular = TRUE, 
       ratio = 0.5) + 
  geom_edge_elbow() + 
  geom_node_text(aes(x = x*1.005, y=y*1.005, filter=leaf, 
                     angle = -((-node_angle(x, y)+90)%%180)+90, label = label), 
                 size=3, hjust='outward') + 
  geom_node_point(aes(filter=leaf)) + 
  coord_fixed() + 
  ggforce::theme_no_axes()

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43153004

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档