给定一组固定的点,我可以绘制它们,并添加显式代码以使用geom_segment连接其中的一些点。如果我有一个单独的数据源,其中包含所有线段的坐标,是否有一种方法在同一图中为这些线段添加循环?
ggplot() +
geom_point(data=cm,mapping = aes(x, y)) +
# connect every two paired assets based on separate data source
geom_segment (mapping=aes(x=10,y=10,xend=100,yend=100), arrow=arrow(angle = 8,type ="closed",length = unit(0.10, "inches")),
size=0.2, linetype=1, color="#cccccc")
+ geom_segment ( ...
数据集:
x,y
10.0, 10.0
100.0, 100.0
...
分段:
x,y,x2,y2
10.0, 10.0, 100.0,100.0
...