knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE, message = FALSE, dev = "ragg_png", dpi = 300, tidy = "styler", out.width = "50%", fig.show = "hold" ) library(tidyterra)
This page shows a gallery of maps that can be displayed with the gradient fill scales included with tidyterra. A basic code to generate this map is:
library(tidyterra) library(terra) library(ggplot2) r <- rast(system.file("extdata/volcano2.tif", package = "tidyterra")) ggplot() + geom_spatraster(data = r) + # Use the palette you like, in this case: scale_fill_hypso_c() + theme_void()
scale_fill_terrain_*
and scale_fill_wiki_*
Check scale_fill_terrain_c()
and scale_fill_wiki_c()
for more info.
r <- terra::rast(system.file("extdata/volcano2.tif", package = "tidyterra" )) library(ggplot2) baseplot <- ggplot() + geom_spatraster(data = r) ss <- baseplot + scale_fill_terrain_c() + labs(title = "terrain") + theme_void() print(ss) ss <- baseplot + scale_fill_wiki_c() + labs(title = "wiki") + theme_void() print(ss)
scale_fill_whitebox_*
Check scale_fill_whitebox_c()
for more info.
allpals <- sort(c( "atlas", "high_relief", "arid", "soft", "muted", "purple", "viridi", "gn_yl", "pi_y_g", "bl_yl_rd", "deep" )) for (i in allpals) { ss <- baseplot + scale_fill_whitebox_c(palette = i) + labs(title = paste0(i)) + theme_void() print(ss) }
scale_fill_hypso_*
Check scale_fill_hypso_c()
for more info.
allpals <- sort(unique(hypsometric_tints_db$pal)) for (i in allpals) { ss <- baseplot + scale_fill_hypso_c(palette = i) + labs(title = paste0(i)) + theme_void() print(ss) }
scale_fill_cross_blended_*
Check scale_fill_cross_blended_c()
for more info.
allpals <- sort(unique(cross_blended_hypsometric_tints_db$pal)) for (i in allpals) { ss <- baseplot + scale_fill_cross_blended_c(palette = i) + labs(title = paste0(i)) + theme_void() print(ss) }
scale_fill_grass_*
Check scale_fill_grass_c()
for more info. Plots produced using
use_grass_range = FALSE
.
allpals <- sort(unique(grass_db$pal)) for (i in allpals) { ss <- baseplot + scale_fill_grass_c(palette = i, use_grass_range = FALSE) + labs(title = paste0(i)) + theme_void() print(ss) }
scale_fill_princess_*
Check scale_fill_princess_c()
for more info.
allpals <- sort(unique(princess_db$pal)) for (i in allpals) { ss <- baseplot + scale_fill_princess_c(palette = i) + labs(title = paste0(i)) + theme_void() print(ss) }
if (!require("sessioninfo")) { install.packages("sessioninfo") } sessioninfo::session_info()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.