尝试做类似的事情:如何创建加纳洪水动画
我的代码如下
library(ggmap)
library(ggplot2)
library(gganimate)
#devtools::install_github("dgrtwo/gganimate")
library(readxl)
s_data <- read_excel("объекты.xls")
head(s_data)
p <- ggmap(get_map(c(32.10399,49.04548), zoom = 5))
p+geom_point(data = s_data, aes(x = longitude, y = latitude, size=channels_contracted, cumulative = TRUE, frame = year), alpha=0.5)+ labs(title = "Objects until 2016 \n")
gganimate(p, outfile = "outfile11.gif", convert = "gm convert", ani.width = 700, title_frame = TRUE)
当试图在地图上获得积分时 - 我有一些关于未知美学(累积,框架)的警告。然后,当我尝试为结果设置动画时 - 我刚刚崩溃 - 请参阅下面的代码输出。
> Warning: Ignoring unknown aesthetics: cumulative, frame Warning
> message: Removed 11 rows containing missing values (geom_point).
> >
> > gganimate(p, outfile = "outfile11.gif", convert = "gm convert", ani.width = 700, title_frame = TRUE) Error in gganimate(p, outfile =
> "outfile11.gif", convert = "gm convert", : No frame aesthetic
> found; cannot create animation
有什么问题,我该如何解决?
如果它很重要 - WindowsX64 ......所以我认为动画,ImageMagock等会有一些困难......
更新:在@lukeA 的帮助下找到了修复似乎在脚本工作期间发生的一些警告使动画生成崩溃了。
工作解决方案:
library(ggmap)
library(ggplot2)
library(gganimate)
library(readxl)
library(animation)
#s_data <- read_excel("C:/Users/fire/OneDrive/Документы/AMICO_WORK/current/объекты.xls")
channels_contracted=c(10,20,30,40,50,70,10,1)
year=c(1999,1999,2000,2000,2001,2002,2003,2003)
latitude=c(44.61217,46.97676,46.66602,46.51235,46.77762, 41.00222, 46.51235,46.77762)
longitude=c(30.72798,30.71394, 31.94281, 30.70631, 33.47262, 29.90559, 30.71394, 30.71775)
type=c("ASZ", "AGS", "ASZ", "AGS", "GNS", "GNS1", "GNS1", "AGS")
df = data.frame(channels_contracted, year, latitude, longitude, type)
p <- ggmap(get_map(c(32.10399,49.04548), zoom = 5))
suppressWarnings(p <- p + geom_point(aes(longitude,latitude,frame=year,cumulative=FALSE, size = channels_contracted, color = type), df, alpha=0.3))
ani.options(interval=2)
gganimate(p)