ggplot2 maps with insets
UPDATE: changed data source so that the entire example can be run by anyone on their own machine. Also, per Joachim’s suggestion, I put a box around the blown up area of the map. In addition, rgeos and maptools removed, not needed. Here’s a quick demo of creating a map with an inset within it using ggplot. The inset is achieved using the gridExtra package. Install libraries install.packages(c("ggplot2", "maps", "grid", "gridExtra")) library("ggplot2") library("maps") library("grid") library("gridExtra") Create a data frame dat <- data.frame(ecosystem = rep(c("oak", "steppe", "prairie"), each = 8), lat = rnorm(24, mean = 51, sd = 1), lon = rnorm(24, mean = -113, sd = 5)) head(dat) #> ecosystem lat lon #> 1 oak 49.58285 -107.6930 #> 2 oak 52.58942 -116.6920 #> 3 oak 50.49277 -114.5542 #> 4 oak 50.05943 -116.5660 #> 5 oak 51.76492 -112.1457 #> 6 oak 52.82153 -112.8858 Get maps using the maps library Get a map of Canada ...