Я строю полигоны, представляющие географические области с точками сверху. Когда я строю их статически, используя ggplot2 , график получается ожидаемым (в частности, цвет заливки полигонов). Однако, когда я добавляю пару строк для анимации графика (используя gganimate ), цвета заливки многоугольника больше не корректны.
Воспроизводимый пример (анимация занимает 4-6 минут для рендеринга):
library(ggplot2)
library(gganimate)
library(readr)
data_points <- read_csv("https://raw.githubusercontent.com/maxtoki2/reprexes/master/points.csv")
area_map <- read_csv("https://raw.githubusercontent.com/maxtoki2/reprexes/master/shapes.csv")
# static plot, looks as expected
ggplot(data = data_points) +
geom_polygon(data = area_map, aes(x = long, y = lat, group = group, fill = area_name), col = "grey70") +
geom_point(aes(x = long, y = lat, col = species, group = id), alpha = .5) +
coord_map() +
scale_fill_manual(values = c("A" = "grey90", "B" = "grey50"), guide = F)
# animation, area fills get scrambled
# WARNING: takes 4-6 minutes
ggplot(data = data_points) +
geom_polygon(data = area_map, aes(x = long, y = lat, group = group, fill = area_name), col = "grey70") +
geom_point(aes(x = long, y = lat, col = species, group = id), alpha = .5) +
coord_map() +
scale_fill_manual(values = c("A" = "grey90", "B" = "grey50"), guide = F) +
labs(subtitle = 'Date: {frame_along}') +
transition_reveal(date_seen)
Вот информация о моей сессии.
(64-bit) Running under: Windows 10 x64 (build 16299)
Matrix products: default
locale: [1] LC_COLLATE=English_United States.1252
LC_CTYPE=English_United States.1252 LC_MONETARY=English_United
States.1252 [4] LC_NUMERIC=C
LC_TIME=English_United States.1252
attached base packages: [1] stats graphics grDevices utils
datasets methods base
other attached packages: [1] gganimate_1.0.3 ggplot2_3.2.1
readr_1.3.1 repmis_0.5
loaded via a namespace (and not attached): [1] Rcpp_1.0.2
pillar_1.4.2 compiler_3.5.0 plyr_1.8.4
R.methodsS3_1.8.0 prettyunits_1.0.2 [7] R.utils_2.9.2 tools_3.5.0
progress_1.2.2 zeallot_0.1.0 digest_0.6.21 tibble_2.1.3
[13] gtable_0.3.0 R.cache_0.14.0 png_0.1-7
pkgconfig_2.0.3 rlang_0.4.0 rstudioapi_0.10 [19]
mapproj_1.2.7 curl_4.2 withr_2.1.2 httr_1.4.1
dplyr_0.8.3 maps_3.3.0 [25] vctrs_0.2.0 hms_0.5.1
grid_3.5.0 tidyselect_0.2.5 glue_1.3.1
data.table_1.12.4 [31] R6_2.4.0 gifski_0.8.6
farver_1.1.0 tweenr_1.0.1 purrr_0.3.2 magrittr_1.5
[37] backports_1.1.5 scales_1.0.0 assertthat_0.2.1
colorspace_1.4-1 labeling_0.3 stringi_1.4.3 [43]
lazyeval_0.2.2 munsell_0.5.0 crayon_1.3.4 R.oo_1.23.0
Спасибо за вашу помощь.