如何在R中制作不同半径的圆弧图?

how to make an arc diagram of varying radius in R?

弧线图有多个R包,如ggraph或arcdiagram,但如果有多个不同性质的连接,它将显示为连接相同起点和终点的相同半径的重叠弧线。是否可以用不同半径的圆弧代表不同的类别?像这张粗略的图表中的东西?谢谢!

我们可以使用 ggplot2。让结束点在df中定义为

library(ggplot2)
df <- data.frame(x1 = 2, x2 = 3, y1 = 21, y2 = 15)

然后我们使用geom_curve。似乎我们不能将 curvature 参数用作美学,但 lapply 允许处理:

ggplot(data = df, aes(x = x1, y = y1, xend = x2, yend = y2)) + 
  lapply(-5:5 / 10, function(cu) geom_curve(curvature = cu)) + theme_bw()

为了获得多个对称弧,我使用 curvature 的各种值定义为

A numeric value giving the amount of curvature. Negative values produce left-hand curves, positive values produce right-hand curves, and zero produces a straight line.