How to add geo-spatial connections on a ggplot map?

后端 未结 3 504
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-18 14:13

Using this as a reference, I\'m trying to plot a map of the lower forty-eight and add layers to visualize flow between states.

library(ggplot2)
library(maps)         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-18 14:20

    What strikes me as odd is that you refer to the longitude in two different ways: long in the beginning of the script, and lon in the end. You need to get these names consistent if you expect multiple geom's to work together.

    In addition, adding identical geom's with for loops is almost never needed. Just add a single geom_line and use the color aesthetic to draw multiple lines.

提交回复
热议问题