I'm trying to solve a krigging/ggplot issue. I currently have the plot showing a continuous scale using:
Cu_DTPA_NL.kriged %>%
as.data.frame() %>%
ggplot(aes(x = x, y = y)) +
geom_raster(aes(fill = var1.pred), interpolate = TRUE) +
coord_equal() +
scale_fill_viridis(option = "inferno") +
scale_x_continuous(labels = comma) +
scale_y_continuous(labels = comma) +
theme_bw()
But I want to change is colour ramp to discrete, selecting my own colours, scale, adn include contours but I am unable to get it to work, see example image and code below:
Zn_DTPA_NL.kriged <- krige(Zn ~ 1, DTPA_North, North_krige_grid, model = lzn_DTPA_NL.fit)
Zn_DTPA_NL.kriged %>%
as.data.frame() %>%
ggplot(aes(x = x, y = y)) +
geom_raster(aes(fill = var1.pred), interpolate = TRUE) +
coord_equal() +
scale_colour_manual(
breaks = c("550", "650", "750", "850"),
labels = c("550", "650", "750", "850"),
values = c(
"#0000FF", "#33CCFF",
"#99FF99", "#FFCC33", "#CC0000"
)
) +
scale_fill_manual(
breaks = c("550", "650", "750", "850"),
labels = c("550", "650", "750", "850"),
values = c(
"#0000FF", "#33CCFF",
"#99FF99", "#FFCC33", "#CC0000"
)
) +
scale_x_continuous(labels = comma) +
scale_y_continuous(labels = comma) +
theme_bw()
Any advice will be great!