Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# Establish the vector scalar for the wind
wind_uv_scalar <- 0.5
# The bottom figure (air)
mg_bottom <- ggplot(data = southern_africa_coast, aes(x = lon, y = lat)) +
# The ocean temperature
geom_raster(data = air_temp, aes(fill = value)) +
# The land mass
geom_polygon(aes(group = group), fill = NA, colour = "black", size = 0.5, show.legend = FALSE) +
geom_path(data = africa_borders, aes(group = group)) +
# The current vectors
geom_segment(data = winds, aes(xend = lon + u * wind_uv_scalar, yend = lat + v * wind_uv_scalar),
arrow = arrow(angle = 15, length = unit(0.02, "inches"), type = "closed"), alpha = 0.4) +
# The legend for the vector length
geom_label(aes(x = 36, y = -37, label = "4.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)) +
# Improve on the x and y axis labels
scale_x_continuous(breaks = seq(15, 35, 5),
labels = scales::unit_format("°E", sep = "")) +
scale_y_continuous(breaks = seq(-35, -30, 5),
labels = c("35°S", "30°S")) +
labs(x = NULL, y = NULL) +
# Scale bar
scaleBar(lon = 13, lat = -38.0, distanceLon = 200, distanceLat = 50, distanceLegend = 90, dist.unit = "km",
arrow.length = 200, arrow.distance = 130, arrow.North.size = 4) +
# 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 = "A") +
# 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