6.3 Plot Maps

  • We can also plot the data on a map 6.6
# take last day's data data from d2
d2 = d2[d2$Date == max(d2$Date), ]
world = map_data("world")
w1 = ggplot() + geom_polygon(data = world, aes(color = region, x = long, y = lat,
    group = group), fill = "white") + theme_map() + theme(legend.position = "none") +
    scale_fill_brewer(palette = "Blues")
map1 = w1 + geom_point(aes(x = Long, y = Lat, size = Cases, colour = Country), data = d2) +
    labs(title = paste("COVID-19 Cases as of ", as.character(unique(d2$Date))))
# static version
map1
Map

Figure 6.6: Map

  • Interactive version using plotly 6.7
# interactive version
map2 = ggplotly(map1, originalData = FALSE, tooltip = c("colour", "size"), width = 750)
map2