Description Usage Arguments Value Examples
Plot map with ggplot
1 2 3 4 5 6 7 | plot_ggmap(
x,
col_name = "confirmedCount",
province_language = "chinese",
show_capitials = TRUE,
add_title = NA
)
|
x |
data frame with province name and value |
col_name |
column whose value is to display |
province_language |
chinese, english or NA (not shown) |
show_capitials |
logical. |
add_title |
title |
a ggplot map
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 | require(ncovr)
library(ggplot2)
library(dplyr)
library(scales)
Sys.setlocale("LC_CTYPE", "Chinese")
ncov <- get_ncov()
ncov$area$date <- as.Date(ncovr:::conv_time(ncov$area$updateTime))
choose_date <- "2020-02-10"
x <- ncov$area[ncov$area$date <= as.Date(choose_date), ]
x <- x[!duplicated(x$provinceName), ]
plot_ggmap(x)
plot_ggmap(x, province_language = "english", show_capitials = TRUE) +
annotate(geom = "text", 105, y = 35, label = "ncov2020.org", color = "white",
fontface = "bold", size = 10, alpha = 0.5)
library(animation)
ncov_dates <- as.character(rev(unique(ncov$area$date)))
ani.options(interval = 0.5, ani.width = 1000, ani.height = 600)
saveGIF({
for (i in rev(ncov_dates)) {
x <- ncov$area[ncov$area$date <= as.Date(i), ]
x <- x[!duplicated(x$provinceName), ]
print(plot_ggmap(x, ))
}
}, movie.name = "map_animation.gif")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.