library(ggmap)
library(ggrepel)
library(mapdata)
library(showtext)
library(stringr)
library(RColorBrewer)
font_add_google("Fira Sans", "fira")
showtext_auto()
langs <- read.csv("./langs.csv")
world <- map_data("world")
colours <- sample(colorRampPalette(brewer.pal(12, "Paired"))(100), 100)
map <- ggplot() +
coord_map(
projection = "mollweide",
xlim = c(-180, 180), ylim = c(-90, 90)
) +
geom_polygon(
data = world,
aes(x = long, y = lat, group = group),
alpha = .33, fill = "#2176d1"
) +
geom_text_repel(
aes(
x = langs$long, y = langs$lat,
label = str_glue("{langs$language} ({langs$glottocode})")
),
# label = paste(langs$language, langs$glottocode, sep = " ")),
position = position_jitter(width = 0.1, height = 0),
size = 2.5,
box.padding = .15,
segment.size = 0.1,
min.segment.length = 0.2,
family = "fira"
) +
geom_point(aes(
x = langs$long, y = langs$lat,
shape = langs$genus,
col = langs$genus
), size = 3.00) +
scale_shape_manual(values = rep(c(
"■", "□",
"▲", "△",
"▶", "▷",
"▼", "▽",
"◀", "◁",
"◆", "◇",
"●", "○",
"◐", "◑"
), 9)) +
scale_colour_manual(values = colours) +
theme_minimal() +
labs(col = "Genera", shape = "Genera") +
theme(
axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
panel.grid.major = element_blank(),
text = element_text(size = 8, family = "fira"),
legend.title = element_text(hjust = 0),
legend.direction = "vertical",
legend.key.height = unit(0.15, "cm"),
legend.key.width = unit(.1, "cm"),
legend.position = "top"
) +
guides(color = guide_legend(ncol = 5), shape = guide_legend(ncol = 8))
ggsave(filename = "langs.pdf", device = "pdf", width = 30, unit = "cm")Language map code
R code for language map
I used the software R (R Core Team 2019) and in particular the package ggmap (Kahle & Wickham 2013). The code I used is shown in Listing 1.
language,family,genus,glottocode,iso,lat,long
English,Indo-European,Germanic,stan1293,eng,53,1
Hungarian,Uralic,Ugric,hung1274,hun,46.91,19.66
Itelmen,Chukotko-Kamchatkan,Kamchatkan,itel1242,itl,56.05,156.31References
Kahle, David & Hadley Wickham. 2013. Ggmap: Spatial visualization with ggplot2. The R Journal 5(1). 144–161.
R Core Team. 2019. R: A language and environment for statistical computing. Vienna, Austria: R Foundation for Statistical Computing.