我有空间点,沿着海岸线,在几年之间。使用this的答案,我绘制了点,并使用滑块控制不透明度来显示不同的年份。
目前是否可以在使用ggvis时覆盖简单的地图,可能使用ggmap或任何其他地图包?
library(ggmap)
library(ggvis)
#simple dataset
long <- c(-53.53167, -53.53167, -53.68000, -53.64667, -53.68500)
lat <- c(47.16833, 47.18500, 47.01167, 47.00500, 47.98833)
year <- c(1995:1999)
count <- rpois(5, 20)
data1 <- as.data.frame(cbind(year, count, lat, long))
#interactive data visual, with the goal of having a map in the background
data %>%
ggvis(~long, ~lat, size=~count) %>%
layer_points(opacity=input_slider(min(data$year), max(data$year), step=1,map=function(x) ifelse(data$year == x, 1, 0)))
#in ggmap, an example of a potential map to make interactive
mylocation <- c(min(long), min(lat))
mymap <- get_map(location=mylocation, source="google", maptype="roadmap", zoom = 8)
ggmap(mymap) + geom_point(data=data1, aes(x=long, y=lat, size=count), alpha=0.6)