Created
July 17, 2017 23:03
-
-
Save robwschlegel/006e65ae675eb63f73d03bfc2bad98c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Establish the vector scalar for the currents | |
current_uv_scalar <- 2 | |
# The top figure (sea) | |
mg_top <- ggplot(data = southern_africa_coast, aes(x = lon, y = lat)) + | |
# The ocean temperature | |
geom_raster(data = sea_temp, aes(fill = value)) + | |
# The bathymetry | |
stat_contour(data = sa_bathy[sa_bathy$depth < -200 & sa_bathy$depth > -2000,], | |
aes(x = lon, y = lat, z = depth, alpha = ..level..), | |
colour = "ivory", size = 0.5, binwidth = 1000, na.rm = TRUE, show.legend = FALSE) + | |
# The current vectors | |
geom_segment(data = currents, aes(xend = lon + u * current_uv_scalar, yend = lat + v * current_uv_scalar), | |
arrow = arrow(angle = 15, length = unit(0.02, "inches"), type = "closed"), alpha = 0.4) + | |
# The land mass | |
geom_polygon(aes(group = group), fill = "grey70", colour = "black", size = 0.5, show.legend = FALSE) + | |
geom_path(data = africa_borders, aes(group = group)) + | |
# The legend for the vector length | |
geom_label(aes(x = 36, y = -37, label = "1.0 m/s\n"), size = 3, label.padding = unit(0.5, "lines")) + | |
geom_segment(aes(x = 35, y = -37.5, xend = 37, yend = -37.5)) + | |
# The in situ sites | |
geom_point(data = site_list, shape = 1, size = 2.4, colour = "ivory") + | |
geom_text(data = site_list, aes(label = order), size = 1.6, colour = "red") + | |
# Oceans | |
annotate("text", label = "INDIAN\nOCEAN", x = 37.00, y = -34.0, size = 4.0, angle = 0, colour = "ivory") + | |
annotate("text", label = "ATLANTIC\nOCEAN", x = 13.10, y = -34.0, size = 4.0, angle = 0, colour = "ivory") + | |
# Benguela | |
geom_segment(aes(x = 17.2, y = -32.6, xend = 15.2, yend = -29.5), | |
arrow = arrow(length = unit(0.3, "cm")), size = 0.5, colour = "ivory") + | |
annotate("text", label = "Benguela", x = 16.0, y = -31.8, size = 3.5, angle = 298, colour = "ivory") + | |
# Agulhas | |
geom_segment(aes(x = 33, y = -29.5, xend = 29.8, yend = -33.0), | |
arrow = arrow(length = unit(0.3, "cm")), size = 0.5, colour = "ivory") + | |
annotate("text", label = "Agulhas", x = 31.7, y = -31.7, size = 3.5, angle = 53, colour = "ivory") + | |
# Agulhas Bank | |
annotate("text", label = "Agulhas\nBank", x = 22.5, y = -35.5, size = 3.0, angle = 0, colour = "ivory") + | |
# Cape Peninsula | |
annotate("text", label = "Cape\nPeninsula", x = 17.2, y = -35, size = 3.0, angle = 0, colour = "ivory") + | |
# Improve on the x and y axis labels | |
scale_x_continuous(breaks = seq(15, 35, 5), | |
labels = scales::unit_format("°E", sep = ""), | |
position = "top") + | |
scale_y_continuous(breaks = seq(-35, -30, 5), | |
labels = c("35°S", "30°S")) + | |
labs(x = NULL, y = NULL) + | |
# Slightly shrink the plotting area | |
coord_cartesian(xlim = c(10.5, 39.5), ylim = c(-39.5, -25.5), expand = F) + | |
# Use viridis colour scheme | |
scale_fill_viridis(name = "Temp.\n(°C)", option = "D") + | |
# Adjust the theme | |
theme_bw() + | |
theme(panel.border = element_rect(fill = NA, colour = "black", size = 1), | |
axis.text = element_text(colour = "black"), | |
axis.ticks = element_line(colour = "black")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment