-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimate-data.R
More file actions
151 lines (134 loc) · 6.71 KB
/
animate-data.R
File metadata and controls
151 lines (134 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#========================================"GRAFICOS ANIMADOS"=======================================
# Representando los casos Cuba vs TOP - 10
### Tema claro
casos.top.10.cu.anim <- casos.top.10.cu %>%
ggplot(aes(x = dateRep, y = casos.acum)) +
geom_line(aes(colour = countryterritoryCode), size = 1.5, alpha = 0.5, show.legend = F) +
geom_flag(aes(country = geoId), size = 8) +
labs(x = "Fecha", y = "Cantidad de Casos",
title = paste0("Evolución de Casos\n TOP-10 Paises más Cuba - ",
"Datos cierre: ", format(Sys.Date(), "%A, %d de %B de %Y")),
caption ="Fuente de datos: Centro europeo para la prevención y el control de enfermedades\n
Enlace a fichero de datos: https://www.ecdc.europa.eu/sites/default/files/documents/COVID-19-geographic-disbtribution-worldwide-2020-05-15.xlsx\n
Gráfico realizado por: Frank Rodríguez López") +
theme_ATHENDAT_claro() +
theme(axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank()) +
transition_reveal(dateRep) +
ease_aes('linear')
# animate(casos.top.10.cu.anim, width = 900, height = 506, nframes = 560, fps = 50)
image_write_gif(animate(casos.top.10.cu.anim,
width = 900,
height = 506,
nframes = 560,
fps = 50,
rendere = magick_renderer()),
"figs/casos.top.10.cu.anim.gif")
`tasa.10^5.top.10.cu.anim` <- casos.top.10.cu %>%
ggplot(aes(x = dateRep, y = `tasa.10^5.hab.acum`)) +
geom_line(aes(colour = geoId), size = 1.5, alpha = 0.5, show.legend = F) +
geom_flag(aes(country = geoId), size = 8) +
labs(x = "Fecha", y = "Cantidad de Casos",
title = paste0("Evolución de Casos\n TOP-10 Paises más Cuba - ",
"Datos cierre: ",
format(Sys.Date(), "%A, %d de %B de %Y")),
subtitle = "Normalizado por cien mil habitantes.",
caption ="Fuente de datos: Centro europeo para la prevención y el control de enfermedades\n
Enlace a fichero de datos: https://www.ecdc.europa.eu/sites/default/files/documents/COVID-19-geographic-disbtribution-worldwide-2020-05-15.xlsx\n
Gráfico realizado por: Frank Rodríguez López") +
theme_ATHENDAT_claro() +
theme(axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank()) +
transition_reveal(dateRep) +
ease_aes('linear')
# animate(`tasa.10^5.top.10.cu.anim`, width = 900, height = 506, nframes = 560, fps = 50)
image_write_gif(animate(`tasa.10^5.top.10.cu.anim`,
width = 900,
height = 506,
nframes = 560,
fps = 50,
renderer=magick_renderer()),
"figs/`tasa.10^5.top.10.cu.anim`.gif")
`tasa.10^5.top.10.cu.anim.n` <- casos.top.10.cu %>%
ggplot(aes(x = dateRep, y = `tasa.10^5.hab.acum`)) +
geom_line(aes(colour = geoId), size = 1.5, alpha = 0.5, show.legend = F) +
geom_flag(aes(country = geoId), size = 8) +
labs(x = "Fecha", y ="Cantidad de Casos",
title = paste0("Evolución de Casos\n TOP-10 Paises más Cuba - ",
"Datos cierre: ",
format(Sys.Date(), "%A, %d de %B de %Y")),
subtitle = "Normalizado por cien mil habitantes.",
caption ="Fuente de datos: Centro europeo para la prevención y el control de enfermedades\n
Enlace a fichero de datos: https://www.ecdc.europa.eu/sites/default/files/documents/COVID-19-geographic-disbtribution-worldwide-2020-05-15.xlsx\n
Gráfico realizado por: Frank Rodríguez López") +
dark_mode(theme_ATHENDAT_claro()) +
theme(axis.text.x = element_text(angle = 17, hjust = 1),
panel.grid.major.x = element_blank()) +
transition_reveal(dateRep) +
ease_aes('linear')
# animate(`tasa.10^5.top.10.cu.anim.n`, width = 900, height = 506, nframes = 560, fps = 50)
image_write_gif(animate(`tasa.10^5.top.10.cu.anim.n`,
width = 900,
height = 506,
nframes = 560,
fps = 50,
renderer=magick_renderer()),
"figs/`tasa.10^5.top.10.cu.anim.n`.gif")
casos.prov.tiempo.anim <- casos.prov.tiempo %>%
ggplot(aes(x = casos.acum.prov,
y = casos,
group = provincia,
color = provincia)) +
geom_line(show.legend = F) +
geom_point(show.legend = F) +
scale_y_log10() +
scale_x_log10() +
labs(x = "Casos Acumulados", y = "Casos Nuevos",
title = paste0("Crecimiento de nuevos Casos por Provincias\n", "Datos cierre: ", format(Sys.Date() - 1, "%A, %d de %B de %Y")),
subtitle = ,
caption = "Fuente de datos: https://covid19cubadata.github.io/#cuba\n
Enlace a fichero de datos : https://covid19cubadata.github.io/data/covid19-casos.csv\n
Gráfico realizado por: Frank Rodríguez López") +
theme(panel.grid.minor = element_blank()) +
facet_wrap(~provincia) +
theme_ATHENDAT_claro() +
theme(axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank()) +
transition_reveal(fecha_confirmacion) +
ease_aes('linear')
image_write_gif(animate(casos.prov.tiempo.anim,
width = 900,
height = 900,
nframes = 560,
fps = 50,
renderer=magick_renderer()),
"figs/casos.prov.tiempo.anim.gif")
casos.tiempo.eventos.anim <- casos.tiempo.eventos %>%
ggplot(aes(x = Fecha,
y = Cantidad,
group = Evento,
color = Evento)) +
geom_line(alpha = 0.5,
size = 2.5) +
geom_point(alpha = 0.5,
size = 5) +
scale_x_date(breaks = "2 weeks") +
scale_color_manual(values = pal) +
labs(x = "Fecha",
y = "Cantidad de Casos",
title = "Evolución de casos por Evento en el tiempo.",
subtitle = paste0("Datos cierre: ", format(Sys.Date() - 1, "%A, %d de %B de %Y")),
caption = "Fuente de datos: https://covid19cubadata.github.io\n
Enlace a fichero de datos: https://covid19cuba.github.io/covid19cubadata.github.io/api/v1/evolution_of_cases_by_days.json\n
Gráfico realizado por: Frank Rodríguez López") +
theme_ATHENDAT_claro() +
theme(axis.text.x = element_text(angle = 17, hjust = 1)) +
transition_reveal(Fecha) +
ease_aes('linear')
image_write_gif(animate(casos.tiempo.eventos.anim,
width = 900,
height = 600,
nframes = 560,
fps = 25,
renderer = magick_renderer()),
"figs/casos.tiempo.eventos.anim.gif")