如何在ggraph径向图中读取文本标签
在如何在ggraph径向图中读取文本标签,r,ggplot2,ggraph,ggforce,R,Ggplot2,Ggraph,Ggforce,在ggraph中,如果绘图是径向的,则标签可能会变得拥挤,无论是否使用repel=T 是否有一种方法可以使标签交互或允许旋转图形以读取标签 library(ggraph) mtcarsDen <- as.dendrogram(hclust(dist(mtcars[1:4], method='euclidean'), method='ward.D2')) ggraph(graph = mtcarsDen, layout = 'den
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)
mtcarsDen您可以这样修改角度美学:
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()