abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
我建议覆盖两个 geom_link_edges - 第一个具有节点之间的完整链接,第二个具有末尾有箭头的部分链接。我能够通过您的示例实现这一点,如下所示:
library(ggraph)
library(ggplot2)
# make edges
edges = data.frame(from = c("A", "B", "C"),
to = c("C","A", "B"),
relative_position = c(.6,.1, .4))
# create graph
graph <- as_tbl_graph(edges)
# plot using ggraph
ggraph(graph) +
geom_edge_link() +
#this the partial link with the arrow - calculate new end coordinates
geom_edge_link(aes(xend=((xend-x)*relative_position)+x,
yend=((yend-y)*relative_position)+y)
arrow = arrow()) +
geom_node_label(aes(label = name))