I am attempting to recreate this graphic:
Proportion of male snails in New Zealand lakes
This image shows an outline of New Zealand, with the pie charts distributed outside of the outline, and connected to lake coordinates with a line. So far, I have code which creates pie charts on top of the coordinates of each lake:
library(raster)
library(rgdal)
library(scatterpie)
## Download data from GADM - country level (0), no regional outlines
nz1 <- getData("GADM", country = "NZ", level = 0)
## Extract polygon corners and merge with shapefile data
nz1@data$id <- rownames(nz1@data)
nz1.ff <- fortify(nz1)
nz1.df <- merge(nz1@data, nz1.ff, by = "id", all.y = TRUE)
#Add datapoints for lakes (longitude & latitude of each lake, with male and female frequencies)
lakes <- read.csv("Map Pie Charts.csv")
## Plot map
ggplot() +
geom_polygon(data = nz1.df, aes(x = long, y = lat, group = group), fill="whitesmoke") +
geom_path(data=nz1.df, aes(long,lat, group=group), color="grey", size=0.1) +
scale_x_continuous(limits=c(165, 180)) +
scale_y_continuous(limits=c(-50, -30)) +
geom_scatterpie(aes(x=long, y=lat), data=lakes, cols=c("Males", "Females"))
Map with pies over lake coordinates My question is whether there is code to adjust the placement of the pie charts, without manually entering new coordinates where I want them? I've seen posts that "jitter" does not work.
Thank you for any help!