Counts for participants by country for the 2020 Annual Society for the Neurobiology of Language Conference.
snl_dat <- read.csv(here("data", "snl20.csv"))
head(snl_dat)
country | count |
---|---|
Argentina | 2 |
Australia | 10 |
Bangladesh | 1 |
Belgium | 10 |
Brazil | 1 |
Canada | 50 |
world_map <- map_data("world") %>% filter(region != "Antarctica") %>% fortify
ggplot(world_map, aes(x = long, y = lat, group = group)) + geom_polygon(fill = "white",
colour = "darkgray") + theme(panel.background = element_rect(fill = "#ebfcf9"))
Another way
p <- ggplot() + geom_map(data = world_map, map = world_map, aes(x = long, y = lat,
group = group, map_id = region), fill = "lightgray", colour = "white", size = 0.5) +
theme(plot.background = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), panel.border = element_blank(), axis.ticks = element_blank(),
axis.text.x = element_blank(), axis.text.y = element_blank(), legend.position = "top-right",
legend.direction = "horizontal")
print(p)
for continuous plotting of counts on a map.
greencols <- brewer.pal(9, "Greens")
newcol <- colorRampPalette(greencols)
ncols <- 100
greenpal <- newcol(ncols) #apply the function to get 100 greens
par(mar = c(0, 0, 0, 0)) #bottom, left, top, right
pie(rep(1, ncols), col = greenpal, border = NA, labels = NA)
The earth is round.
round <- ggplot() + geom_map(data = world_map, map = world_map, aes(x = long, y = lat,
group = group, map_id = region), fill = "white", colour = "darkgray", size = 0.25) +
geom_map(data = snl_dat, map = world_map, aes(map_id = country, fill = count),
colour = "darkgray", size = 0.25) + scale_fill_distiller(guide = "colourbar",
aesthetics = "fill", palette = greenpal, direction = 1) + coord_map("rectangular",
lat0 = 0, xlim = c(-180, 180), ylim = c(-50, 90)) + ggtitle(" SNL2020: Where in the world are we from??") +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.border = element_blank(), axis.ticks = element_blank(), axis.text.x = element_blank(),
axis.text.y = element_blank(), legend.position = c(1, 1), legend.justification = c("right",
"top"), legend.box.just = "right", legend.direction = "horizontal") +
theme(plot.background = element_rect(fill = "#d9ecff"))
print(round)
ggsave("NewSNLMap.pdf")
flat <- ggplot() + geom_map(data = world_map, map = world_map, aes(x = long, y = lat,
group = group, map_id = region), fill = "lightgray", colour = "white", size = 0.25) +
geom_map(data = snl_dat, map = world_map, aes(map_id = country, fill = count),
colour = NA) + scale_fill_viridis_c(guide = "colourbar", aesthetics = "fill",
direction = -1) + ggtitle("SNL2020: Where in the world are we from?") + theme(plot.background = element_blank(),
panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(),
axis.ticks = element_blank(), axis.text.x = element_blank(), axis.text.y = element_blank(),
legend.position = "top", legend.direction = "horizontal")
print(flat)