随着时间的推移绘制地图上的点,其中点的透明度基于R

时间:2016-12-08 00:55:53

标签: r animation ggplot2 maps shapefile

Long    |Lat    |Year   |Cases  
-2.12345|51.456 |1      |2
-2.12345|51.456 |2      |4
-2.12345|51.456 |3      |1
-2.5678 |51.656 |1      |0
-2.5678 |51.656 |2      |5
-2.5678 |51.656 |3      |9
-2.7654 |51.945 |1      |8
-2.7654 |51.945 |2      |5
-2.7654 |51.945 |3      |6

我可以在GAD地图上绘制long和lat。

library(sp)
gadmuk <- readRDS(file.choose())
library(rgeos)
uksimpl <- gSimplify(gadmuk, tol = 0.03)
plot(uksimpl)
plot(uksimpl, col = 'lightgrey', border = 'darkgrey', xlim = c(-1, 1), ylim = c(50, 59))
points(x = df$lon, y = df$lat, col = 4, pch = 18)

我想绘制长点和纬线,其中点的透明度根据情况col中的数字而变化。加班加点。因此,所有第1年都是首先绘制的(它们都具有相同的长度和纬度),然后是第2年和所有第3年。

我已经尝试过将其写入循环for i in 3并使用ggplot

map <- uksimpl + geom_point(data = df, 
                            aes(x = Lon, y = Lat, alpha = df$case), 
                            size=5, col=4)

我想知道使用动画和shapefile而不是GGplot?

0 个答案:

没有答案