我正在尝试在地图上的特定坐标上绘制玫瑰图/圆形直方图,类似于在包中的地图上绘制饼图mapplots
。
下面是一个生成的示例mapplots
(代码见下文),我想用玫瑰图替换饼图
该软件包circular
允许我绘制玫瑰图,但我无法将其与mapplots
软件包集成。对实现此目的的替代包或代码有什么建议吗?
针对制作地图的代码的问题。这一切都基于mapplots
包。我下载了地图的 shapefile(我认为来自http://www.freegisdata.org/)
library(mapplots)
library(shapefiles)
xlim = c(-180, 180)
ylim = c(-90, 90)
#load shapefile
wmap = read.shapefile ("xxx")
# define x,y,z for pies
x <- c(-100, 100)
y <- c(50, -50)
z1 <- c(0.25, 0.25, 0.5)
z2 <- c(0.5, 0.2, 0.3)
z <- rbind(z1,z2)
# define radii of the pies
r <- c(5, 10)
# it's easier to have all data in a single df
plot(NA, xlim = xlim, ylim = ylim, cex = 0.75, xlab = NA, ylab = NA)
draw.shape(wmap, col = "grey", border = "NA")
draw.pie(x,y,z,radius = r, col=c("blue", "yellow", "red"))
legend.pie (x = -160, y = -70, labels = c("0", "1", "2"), radius = 5,
bty = "n", cex = 0.5, label.dist=1.5, col = c("blue", "yellow", "red"))
然后可以使用 legend.bubble 添加饼图大小的图例