I'm trying to get two separate gradients for land and water on a map. I am able to get the water gradient (first figure), but not the land.
How can I set a grey gradient for land in this code (similar to figure 2 below)?
Sample data
library(marmap)
library(ggplot2)
greys <- c(grey(0.6), grey(0.93), grey(0.99))
# Get map data
bat <- getNOAA.bathy(-68, -51, -48, -39, res = 1, keep = TRUE)
Generate Plot with water gradient
autoplot(bat, geom = c("raster", "contour"), colour = "white", size = 0.1) +
scale_fill_gradientn(limits = c(-6600, 0), colors = c("steelblue4", "#C7E0FF")) +
NULL
I have tried setting different limits in scale_fill_gradientn
, but without much luck:
autoplot(bat, geom = c("raster", "contour"), colour = "white", size = 0.1) +
scale_fill_gradientn(limits = c(min(bat), max(bat)),
colors = c("steelblue4", "#C7E0FF", greys)) +
NULL
Desired output (done using base R's plotting functions)
plot(bat, image = TRUE, land = TRUE, lwd = 0.1, bpal = list(c(0, max(bat), greys), c(min(bat), 0, blues)))
plot(bat, lwd = 0.8, deep = 0, shallow = 0, step = 0, add = TRUE) # highlight coastline