问题描述
我有以下情况:
library(sp)
library(ggplot2)
library(animation)
# Let's create a polygon...
x <- c(0,50,0)
y <- c(0,0)
xy <- cbind(x,y)
p <- polygon(xy)
ps <- polygons(list(p),1)
sps <- Spatialpolygons(list(ps)) # Just an example,the actual polygon is a continent
# ... and place some points with data within it
z <- data.frame(lon = runif(10,0.1,49.9),lat = runif(10,a = runif(10,10,90),b = runif(10,150),c = runif(10,d = runif(10,500,1500),e = runif(10,90))
# And Now let's create an animated gif
saveGIF({
for (j in 3:7) {
temp <- z[,c(1,2,j)]
colnames(temp) <- c("lon","lat","dif")
g <- ggplot() +
geom_polygon(data = sps,aes(x = x,y = y),colour = "gray",fill = NA) +
geom_point(data=temp,color = "blue",alpha = 0.5,aes(x=lon,y=lat,size = dif)) +
annotate(geom="text",x=45,y = 45,size = 10,label = colnames(z)[j])
plot(g)
}
})
如您在此处看到的,地图的宽度随着图例宽度的变化而扩展/放大。我想防止它发生。我想要的是强制图例宽度保持恒定,因为它是最宽的(即:“ d”)。 我已经尝试了here的建议,但没有令人满意的结果。有什么建议吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)