无法使用geom_map获得地图的动画

时间:2018-12-25 09:55:08

标签: r animation

我一直在尝试获取多年来容易绘制的Choropleth贴图的动画,但是我无法获得一个时间序列的动画。

我的代码如下。

q <- ggplot() + geom_map(data = cg2, aes(map_id = Pr_mlnyn, fill = gdp), 
                    map =china) +
  expand_limits(x = china$long, y = china$lat) + 
  coord_fixed(1.3) +
  transition_reveal(year) +
  ease_aes('linear')

animate(q, 3, 1)

我的数据如下。

structure(list(Pr_mlnyn = c("Beijing", "Tianjin", "Hebei", "Shanxi", 
"Inner Mongolia", "Liaoning", "Jilin", "Heilongjiang", "Shanghai", 
"Jiangsu", "Zhejiang", "Anhui", "Fujian", "Jiangxi", "Shandong", 
"Henan", "Hubei", "Hunan", "Guangdong", "Guangxi", "Hainan", 
"Chongqing", "Sichuan", "Guizhou", "Yunnan", "Tibet", "Shaanxi", 
"Gansu", "Qinghai", "Ningxia", "Xinjiang", "Beijing", "Tianjin", 
"Hebei", "Shanxi", "Inner Mongolia", "Liaoning", "Jilin", "Heilongjiang", 
"Shanghai", "Jiangsu", "Zhejiang", "Anhui", "Fujian", "Jiangxi", 
"Shandong", "Henan", "Hubei", "Hunan", "Guangdong", "Guangxi", 
"Hainan", "Chongqing", "Sichuan", "Guizhou", "Yunnan", "Tibet", 
"Shaanxi", "Gansu", "Qinghai", "Ningxia", "Xinjiang", "Beijing", 
"Tianjin", "Hebei", "Shanxi", "Inner Mongolia", "Liaoning", "Jilin", 
"Heilongjiang", "Shanghai", "Jiangsu", "Zhejiang", "Anhui", "Fujian", 
"Jiangxi", "Shandong", "Henan", "Hubei", "Hunan", "Guangdong", 
"Guangxi", "Hainan", "Chongqing", "Sichuan", "Guizhou", "Yunnan", 
"Tibet", "Shaanxi", "Gansu", "Qinghai", "Ningxia", "Xinjiang"
), year = c(2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 
2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 
2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 
2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2012L, 2012L, 2012L, 
2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
2012L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 
2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 
2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 
2017L, 2017L, 2017L, 2017L, 2017L), gdp = c(1111500L, 671901L, 
1601197L, 731540L, 849620L, 1366858L, 642610L, 831437L, 1406986L, 
3098198L, 2146269L, 885166L, 1082301L, 697105L, 3093328L, 1801853L, 
1132892L, 1155500L, 3679671L, 702100L, 150306L, 579366L, 1260123L, 
356156L, 569212L, 39485L, 731458L, 316682L, 101862L, 120392L, 
418321L, 1787940L, 1289388L, 2657501L, 1211283L, 1588058L, 2484643L, 
1193924L, 1369158L, 2018172L, 5405822L, 3466533L, 1721205L, 1970178L, 
1294888L, 5001324L, 2959931L, 2225045L, 2215423L, 5706792L, 1303510L, 
285554L, 1140960L, 2387280L, 685220L, 1030947L, 70103L, 1445368L, 
565020L, 189354L, 234129L, 750531L, 2800035L, 1859538L, 3596400L, 
1497351L, 1610317L, 2394200L, 1528894L, 1619988L, 3013386L, 8590094L, 
5176826L, 2751867L, 3229828L, 2081850L, 7267818L, 4498816L, 3652295L, 
3459056L, 8987923L, 2039625L, 446254L, 1950027L, 3698022L, 1354083L, 
1653134L, 131063L, 2189881L, 767700L, 264280L, 345393L, 1092009L
)), row.names = c(NA, -93L), class = "data.frame")

我不知道我的问题是否仍然需要用于显示中国的多边形。但是,如果需要,我可以发送多边形的强化数据。

0 个答案:

没有答案