簡體   English   中英

如何讀取ggraph徑向圖中的文本標簽

[英]How to read a text label in ggraph radial graph

ggraph ,如果繪圖是徑向的,則無論是否使用repel=T ,標簽都會變得擁擠。

有沒有辦法讓標簽互動或允許旋轉圖形以便閱讀標簽?

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

您可以像這樣修改角度美學:

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

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM