plotting arrows in a map showing shift in position from one place to another

60 views
Skip to first unread message

gafna jeff

unread,
Jul 14, 2020, 10:45:24 AM7/14/20
to ggplot2

Hello everybody,

I have three capital cities in my map (longitudes and latitudes of the points: Buenos aires, Paris and Melbourne are provided below). I would like to draw arrows of different colors and later show the points and arrows on the legend of my map. One arrow should move from Melbourne to Paris (this arrow can be red in color and named first). Another arrow drawn from Paris to Buenos aires (this arrow can be green in color and named second). The cities in the map should be named and can be represented by different shapes ie rectangle, triangle etc. I would really appreciate any help on this.

Regards,

Dikko.


Buenos_aires=c(-58,-34)

Paris=c(2,49)

Melbourne=c(145,-38)

data=rbind(Buenos_aires, Paris, Melbourne) %>% as.data.frame()

colnames(data)=c("long","lat")

points(x=data$long, y=data$lat, col="slateblue", cex=3, pch=20)

##Read in the libararies

library(maptools)

library(rgdal)

library(rgeos)

library(sp)

library(ggplot2)


##get the data

data("wrld_simpl")

crs(wrld_simpl)

plot(wrld_simpl)


##change into a format that can be used in ggplot2

AG <- fortify(wrld_simpl)

names(AG)


###plot with ggplot2 package

ggplot()+ geom_polygon(data=AG, aes(long, lat, group = group), colour = alpha("darkred", 1/2), size = 0.7, fill = 'skyblue', alpha = .3)



Reply all
Reply to author
Forward
0 new messages