diff --git a/inst/make_hexsticker.R b/inst/make_hexsticker.R index 7f7e88f0..2345b094 100644 --- a/inst/make_hexsticker.R +++ b/inst/make_hexsticker.R @@ -1,23 +1,34 @@ +library(covidregionaldata) library(hexSticker) library(showtext) library(ggplot2) library(dplyr) library(maps) +library(countrycode) library(sf) +library(rnaturalearth) +library(rmapshaper) # font setup font_add_google("Zilla Slab Highlight", "useme") # get countries we have data for regional_countries <- get_available_datasets() %>% - filter(type == "regional") + filter(.data$type == "regional") regional_countries_l2 <- regional_countries %>% - filter(!(is.na(level_2_region))) + filter(!(is.na(.data$level_2_region))) # get world data -world <- spData::world %>% - st_as_sf() +world <- ms_simplify(spData::world %>% + st_as_sf(), keep = 0.04) + +regional_maps <- ms_simplify(ne_states(gsub(' \\(.*\\)', "", regional_countries$origin,perl=TRUE), + returnclass = "sf"), keep = 0.04) %>% + mutate( + region_code = paste("Level", woe_id %% 7 + 3) + ) + # mark supported countries from the world data supported_countries <- world %>% @@ -86,6 +97,36 @@ covid_map_2 <- ggplot() + print(covid_map_2) +covid_map_3 <- ggplot() + + ggspatial::layer_spatial(data = supported_countries, aes(fill = fill, size = fill, color = fill)) + + coord_sf(crs = "ESRI:54016") + + scale_fill_manual( + name = "", + values = c("#0072b2", "#cc79a7", "grey80", + "#0072b2", "#cc79a7", "grey80", + "#0072b2", "#cc79a7", "grey80", + "#0072b2", "#cc79a7", "grey80", + "#0072b2", "#cc79a7", "grey80") + ) + + scale_color_manual( + name = "", + values = c("black", "black", "#666666") + ) + + scale_size_manual( + name = "", + values = c(0.1, 0.1, 0.018) + ) + + ggplot() + + ggspatial::layer_spatial(data = regional_maps, + aes(fill = fill, + size = 0.002)) + + coord_sf(crs = "ESRI:54016") + +# scale_fill_brewer(palette = "Blues") + + theme_void() + + theme(legend.position = "none", axis.text.x = element_blank()) + +print(covid_map_3) + logo2 <- sticker( covid_map_2, package = "covidregionaldata", @@ -113,3 +154,4 @@ logo3 <- sticker( u_size = 3.5, dpi = 1000 ) + diff --git a/man/figures/logo1.png b/man/figures/logo1.png index 6ee5038c..6c28bb48 100644 Binary files a/man/figures/logo1.png and b/man/figures/logo1.png differ diff --git a/man/figures/logo2.png b/man/figures/logo2.png index eab7abc9..923fb079 100644 Binary files a/man/figures/logo2.png and b/man/figures/logo2.png differ diff --git a/man/figures/logo3.png b/man/figures/logo3.png index bb0e88fa..2fb7e2d0 100644 Binary files a/man/figures/logo3.png and b/man/figures/logo3.png differ