3

我正在使用 ggraph R 包创建一个图表。我想使用 标记所有节点geom_node_label(),但这通常会产生重叠。一种解决方法是使用repel=TRUE参数。不幸的是,我似乎无法弄清楚如何使边缘指向标签被移动的位置。

解决此问题的一种可能方法可能是在制作图形之前使用排斥进行布局,但我也没有找到解决方法。

library(igraph)
library(ggraph)

# Create example graph
my_graph <- make_graph('Meredith')
V(my_graph)$Label <- 1:70


set.seed(2222) # reproducible layout
ggraph(my_graph) +
    geom_edge_link() +
    geom_node_label(aes(label = Label), repel=FALSE) +
    theme_graph()

# Graph with repel = TRUE
set.seed(2222)
ggraph(my_graph) +
    geom_edge_link() +
    geom_node_label(aes(label = Label), repel=TRUE) +
    theme_graph()

以下是上述代码的图表:

  • 情节1:

在此处输入图像描述

  • 情节2:

在此处输入图像描述

4

0 回答 0