我当前正在try 修改一个字形对象.我使用以下代码创建布局:
graph <- igraph::graph_from_data_frame(d=edge, vertices = nodes, directed = FALSE)
V(graph)$color <- ifelse(nodes[V(graph), 2] == "A", "red",
ifelse(nodes[V(graph), 2] == "B", "blue", "white"))
V(graph)$layer <- ifelse(V(graph)$TYPE == "B",2, ifelse(V(graph)$TYPE == "C", 1,3))
plot_layout <- layout_with_sugiyama(graph, layers = V(graph)$layer)
plot(graph, layout = plot_layout, vertex.size = 5,
vertex.label = NA,
vertex.label.dist = 0, vertex.label.cex = 0.6,
vertex.label.color = "black",
edge.curved = 0.2, edge.width = 1, edge.color=adjustcolor("grey", 0.3))
The result is the following :
问题是,当我为类型为A和C的 node 添加标签时,它们是不可读的,因为 node 彼此太近了.您知道一种方法,可以只将第一层和第三层中的 node 转换为圆弧,而不是直线或间隔 node 吗?
我try 使用ggraph来使用ggrepel来避免标签重叠,但无法使用ggraph中的3层Sugiyama.
谢谢你的帮助.