library(tidyverse)
library(sf)
library(ggtext)
library(rnaturalearth)
library(ggspatial)
library(showtext)
# Load the world map
<- ne_countries(scale = "medium", returnclass = "sf") world
<- data.frame(
memories place = c("Home",
"Holiday",
"Job Abroad",
"Dream Vacation"),
lon = c(12.4964, 2.1686, 0.1276, -74.006),
lat = c(41.9027, 41.3874, 51.5072, 40.7128)
)
# Convert to sf object
<- st_as_sf(memories,
memories_sf coords = c("lon", "lat"),
crs = 4326)
Set the fonts:
font_add_google(name = 'Cormorant Garamond',
family = 'Garamond')
showtext_auto()
ggplot() +
# Base world map
geom_sf(data = world,
fill = alpha("antiquewhite", alpha=0.5),
color = "gray50",
size = 0.3) +
# Highlight the journey locations
geom_sf(data = memories_sf,
aes(geometry = geometry),
color = "darkred",
size = 3) +
geom_text(data = memories,
aes(x = lon, y = lat,
label = place),
nudge_y = 2,
size = 15,
family = "serif",
color = "darkred") +
# Add a soft grid and latitude/longitude lines
coord_sf(ylim = c(20, 60), xlim = c(-90, 20),clip = "off") +
annotation_scale(location = "bl",
width_hint = 0.3,
text_col = "gray30") +
annotation_north_arrow(location = "tr",
style = north_arrow_fancy_orienteering) +
labs(title = "Memories",
subtitle = "Tracing the journey of cherished moments",
caption = "#30DayMapChallenge Day23 | @fgazzelloni") +
::theme_map() +
ggthemestheme(text = element_text(family = "Garamond"),
plot.title = element_text(size = 160,
face = "bold",
hjust = 0.5,
color = "darkred"),
plot.subtitle = element_text(size = 60,
hjust = 0.5,
face = "bold",
color = "gray40"),
plot.caption = element_text(size = 40,
hjust = 0.5,
face = "bold",
color = "gray40"),
panel.background = element_rect(fill = "bisque",
color = NA),
plot.background = element_rect(fill = "white",
color = "white"),
legend.position = "none",
panel.grid.major = element_line(color = "gray90"))
Save the map as png:
ggsave('day23_memory.png',
height = 5, width = 8,
dpi = 300)