if (FALSE) {
# Create continuous color scale - using palette function
my_data <- data.frame(value = c(10, 25, 30, 45, 60, 75, 90))
scale1 <- interpolate_palette(data = my_data, column = "value",
method = "equal", n = 5, palette = viridisLite::plasma)
# Using specific colors (will interpolate to 5 if needed)
scale2 <- interpolate_palette(data = my_data, column = "value",
method = "equal", n = 5, colors = c("red", "yellow", "blue"))
# Or with piping
scale3 <- my_data |> interpolate_palette("value", method = "equal", n = 5)
# Use in a layer
add_fill_layer(map, fill_color = scale1$expression)
# Extract legend information
labels <- get_legend_labels(scale1, format = "currency")
colors <- scale1$colors
}
Run the code above in your browser using DataLab