我正在尝试重新创建此图形:
这张图片显示了新西兰的轮廓,饼图分布在轮廓之外,并用一条线连接到湖泊坐标。到目前为止,我有在每个湖的坐标之上创建饼图的代码:
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"))
在湖坐标上绘制饼图 我的问题是是否有代码可以调整饼图的位置,而无需在我想要的位置手动输入新坐标?我看过“抖动”不起作用的帖子。
感谢您的任何帮助!