2017-04-01 4 views
4

ggraph에서 음모가 방사형 인 경우 repel=T을 사용하든 아니든간에 레이블이 혼잡해질 수 있습니다.ggraph 방사형 그래프에서 텍스트 레이블을 읽는 방법

라벨을 대화 형으로 만들거나 그래프를 회전하여 라벨을 읽을 수있는 방법이 있습니까?

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() 

답변

1

이처럼 각 미학을 수정할 수 있습니다

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() 

enter image description here