[[img/header.png]]
<Description & Motivation>
** Inspiration
** Installation
library(devtools) devtools::install_github("thackl/ggworldmap")
** Usage
library(tidyverse) library(ggworldmap)
ggworldmap(proj = "moll", degree = list("light", long_by = 80))
proj <- "moll" ggplot() + geom_worldmap(proj = proj, color = "gray90", fill = "gray90") + geom_graticule(proj = proj, color = "gray80") + geom_gratframe(proj = proj, color = "gray80") + geom_degree(proj = proj, color = "gray80", long_by = 80) + theme_worldmap_light() + coord_equal()
ggsave("img/ggworldplot.png", width = 12, height = 6, type = "cairo")
[[img/ggworldplot.png]]
long_0 <- 110 ggworldmap(proj = "ortho", long_0 = long_0, mapping = aes(fill=group), long_min = long_0-90, long_max = long_0+90, color = "black", show.legend = FALSE, graticule = list("light", color = "grey20"), degree = list("light", long_n = 3, color = "grey30", family = "Times New Roman")) + scale_fill_distiller(palette = "Pastel2")
ggsave("img/east-asia-countries.png", width = 12, height = 6, type = "cairo")
[[img/east-asia-countries.png]]
data(volcanic_eruptions) # load example data proj <- "robin" # Robinson projection long_0 <- -150 # Center on Pacific ve_proj <- volcanic_eruptions %>% project(proj, long_0) %>% # project data arrange(desc(VEI)) # and get nice plotting order
ggworldmap(ve_proj, long_0 = long_0, proj = proj) + geom_point(aes(size = VEI^4, color = VEI), alpha =.5) + scale_color_distiller(palette = "Spectral")
ggsave("img/pacific-ring-of-fire.png", width = 12, height = 6, type = "cairo")
[[img/pacific-ring-of-fire.png]]
proj <- "robin" # use Robinson projection long_0 <- -120 # center on Pacific lat_min <- -70 # and clip the poles lat_max <- 70
data(volcanic_eruptions) volcanic_eruptions <- volcanic_eruptions %>% filter(Year > 1919) %>% # let's look at last 100 years project(proj, long_0) # and we want our data projected volcanic_eruptions_decluttered <- volcanic_eruptions %>% concentrate(lambda = .2) %>% # round up close points at a single location arrange(Type) # and order them nicely for plotting
gg <- ggplot(mapping = aes(x=long, y=lat)) +
geom_worldmap(proj = proj, long_0 = long_0, lat_min = lat_min, lat_max = lat_max, color = "grey90", fill = "grey90") +
geom_graticule(proj = proj, long_0 = long_0, lat_min = lat_min, lat_max = lat_max, long_by = 40, linetype = 1, color = "grey80", size = .5, alpha=.3) +
geom_graticule(proj = proj, long_0 = long_0, lat_min = lat_min, lat_max = lat_max, lat_n = 2, long_n = 2, linetype = 1, color = "grey80", size = 1) +
geom_degree(proj = proj, long_0 = long_0, lat_min = lat_min, lat_max = lat_max, long_by = 40, color = "grey60", size = 3)
geom_array(aes(color = Type), volcanic_eruptions_decluttered, nrow = 7, spread = 2, shape = 19, size = .8, vjust = .5) +
geom_point(data = volcanic_eruptions, size = .3, alpha = .5) +
ggtitle("Significant Volcanic Eruptions", "of the last 100 years by most common types") +
coord_equal(ylim = c(-80, 80)) +
theme_light(base_size = 15) + theme( panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), axis.title = element_blank(), legend.justification=c(0,1), legend.position=c(.52,.29), legend.text.align=0) +
scale_color_brewer("Eruption types", palette="Dark2") +
facet_wrap(~Type, ncol=2, strip.position = "left")
[[img/volcanic-eruptions.png]]