我想修改我的调色板操作的颜色,以扩大黄色区域,以便我的图中的极值更加突出。我不知道如何改变它,但下面有一个例子。
加载库:
library(tidyterra)
library(ggplot2)
library(terra)
library(dplyr)
创建一个示例数据框,然后将其转换为栅格:
df <- data.frame( x = rep( 0:1, each = 2 ),
y = rep( 0:1, 2),
l = rnorm( 4 ))
df_raster <- rasterFromXYZ(df) %>% terra::rast()
And below, I try to use breaks = to break the color palette into different categories. Unfortunately, it seems to do nothing. I want to expand the yellow region in the middle of the bl_yl_rd, and would be happy to designate certain numbers to indicate where along the values of my raster it should transition colors. Is there a way to do this, or a different function other than scale_fill_whitebox that will do a better job of this?
ggplot() + geom_spatraster(数据 = df_raster) + scale_fill_whitebox_c(调色板=“bl_yl_rd”,休息= 2)
使用
breaks
作为向量,例如:
df <- data.frame( x = rep( 0:1, each = 2 ),
y = rep( 0:1, 2),
l = rnorm( 4 ))
df_raster <- terra::rast(df)
ggplot2::ggplot() +
tidyterra::geom_spatraster(data = df_raster) +
tidyterra::scale_fill_whitebox_b(palette = "bl_yl_rd", breaks = c(0, 1))
创建于 2024-02-29,使用 reprex v2.1.0