r - Is it possible to overlay a scatterplot on map using ggplot? -
i draw map of french departements (ie districts in france) , plot points on map. utilize ggplot2 draw map when want add together points on map, r returns error says cannot find 'group'.
library("ggplot2") library("ggmap") # load contour of french departements wg <- read.csv("data/departements.csv") metropoles <- c("paris", "rennes", "rouen", "lille", "marseille") geo <- geocode(metropoles) met <- data.frame(ville = metropoles, geo) map <- ggplot(data = wg, aes(x = long, y = lat, grouping = group)) + geom_polygon() + scale_x_continuous(limits = c(-7,10)) + scale_y_continuous(limits = c(40,53)) + coord_map() + theme(axis.text = element_blank(), axis.title = element_blank()) map + geom_point(data = met, aes(x = lon, y = lat)) for replication, can find raw info here , r programme here
@roland had answer. problem had defined grouping general argument.
ggplot() + geom_polygon(data = wg, aes(x = long, y = lat, grouping = group)) + scale_x_continuous(limits = c(-7,10)) + scale_y_continuous(limits = c(40,53)) + coord_map() + theme(axis.text = element_blank(), axis.title = element_blank()) geom_point(data = met, aes(x = lon, y = lat)) r ggplot2
No comments:
Post a Comment