[This article was first published on r.iresmi.net, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Day 10 of 30DayMapChallenge : « bad map » (previously).
Just resampling…
library(tidyverse) library(sf) library(glue) library(ggspatial) library(ggrepel) pref <- read_sf("~/adminexpress/adminexpress_simpl.gpkg", layer = "commune") %>% filter(insee_reg > "06", str_detect(statut, "Préfecture de région|Capitale")) %>% mutate(nom = sample(nom)) %>% st_point_on_surface() fr <- read_sf("~/adminexpress/adminexpress_simpl.gpkg", layer = "departement") %>% filter(insee_reg > "06") # map fr %>% ggplot() + geom_sf(color = "grey", fill = "lightgrey") + geom_sf(data = pref, color = "black", size = 1) + geom_text_repel(data = pref, aes(label = nom, geometry = geom), stat = "sf_coordinates", size = 3, bg.color = "#ffffff66", bg.r = 0.2 ) + coord_sf(crs = "EPSG:2154") + labs(title = "France métropolitaine", subtitle = "Get lost", caption = glue("data : based on IGN Adminexpress r.iresmi.net - {Sys.Date()}")) + theme(plot.background = element_rect(fill = "grey10", color = NA), panel.background = element_blank(), panel.grid = element_line(color = "grey20"), plot.title = element_text(color = "grey90", family = "Waree"), plot.subtitle = element_text(color = "grey90"), plot.caption = element_text(color = "grey90", size = 6)) ggsave("bad.png", width = 20, height = 12.36, units = "cm", scale = 1.1)
To leave a comment for the author, please follow the link and comment on their blog: r.iresmi.net.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.