Re
In this post we will present a few examples of interactive and animated maps using both {ggplot2} and {plotly} .
This post is a continuation of the previous one ( interactive and animated maps ) .
This post is just a continuation of the previous post on animated and interactive maps. We will show four examples of maps created using {ggplot2} and {plotly}.
library(tidyverse)
library(gganimate)
library(ggthemes)
library(plotly)
world <- map_data("world") %>%
filter(region != "Antarctica")
meteoritos <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-06-11/meteorites.csv")
options(scipen = 999)
meteoritos_Mundo <- meteoritos %>%
filter(fall == "Fell") %>%
filter(year > 1980) %>%
drop_na() %>%
arrange(mass)
mapa_animado_2 <- world %>%
ggplot() +
geom_polygon(aes( x= long, y = lat, group = group),
fill = "grey20",
color = "white",
size = 0.01) +
geom_point(data= meteoritos_Mundo,
aes(x = long,
y = lat,
frame = year,
size = mass),
color = "orange",
alpha = 0.7) +
labs( title = "Meteorite Landings \n from 1980 to 2013}",
caption = "The Meteoritical Society") +
theme_map() +
scale_size_continuous(guide = F) +
scale_color_discrete(name = "Type") +
theme(plot.title = element_text(size = 10, hjust = 0.5))
fig_2 <- ggplotly(mapa_animado_2) %>% animation_slider(currentvalue = list(prefix = "Year ", font = list(color="orange")))
fig_2