load("chile-map.Rdata")
violencia_chile <- pinochet %>%
select(violence, latitude_1, longitude_1) %>%
filter(!is.na(violence), !is.na(latitude_1), !is.na(longitude_1)) %>%
rename(lat = latitude_1, lon =longitude_1) %>%
mutate(violencia = if_else(violence == "Disappearance","Desaparición",
if_else(violence =="Killed","Asesinado",
if_else(violence=="Disappearance, Information of Death",paste("Desaparición","Información de muerte",sep = "\n"),
if_else(violence=="Suicide","Suicidio","Sin resolver")))))
g <- ggmap(chile_map) +
facet_grid(~violencia) +
geom_pointdensity(data = violencia_chile, aes(x=lon,y=lat),size=5, alpha=.4) +
scale_color_paletteer_c("ggthemes::Red-Green-Gold Diverging",direction = -1)+
labs(title = "Abusos Derechos Humanos",
subtitle = "Régimen de Pinochet",
color = "Densidad",
caption = "Vizualization by @DuvanNievesRui1 | Data: 'Pinochet' • Package Pinochet")+
theme_map()+
theme(legend.background = element_rect(fill = "transparent"),
legend.position = "top",
legend.key.size = unit(1,'cm'),
legend.justification = "center",
plot.margin = unit(rep(.5,4),'cm'),
panel.background = element_rect(fill="grey10",color = "grey10"),
plot.background = element_rect(fill="grey10"),
strip.background = element_rect(fil="grey10", color="grey10"),
plot.title = element_text(size=20, color="grey76",hjust = .5),
plot.subtitle = element_text(size=15, color="grey76",hjust = .5),
plot.caption = element_text(size = 12,color = "grey76", hjust = .98),
strip.text.x =element_text(family = "Roboto Mono",
size = 9,
colour = "grey76"),
legend.title = element_text(family = "Roboto Mono",
size = 12,
colour = "grey76"),
legend.text = element_text(family = "Roboto Mono",
size = 8,
colour = "grey76")) +
transition_layers(layer_length = .001,transition_length = 2,layer_order = c(2,4,3,1)) +
shadow_mark()+
enter_fade() + enter_grow() +
exit_fade() + exit_shrink()
animate(g, renderer = gifski_renderer(),height = 750, width =750,fps = 20)