geom_contour_filled 调色板
geom_contour_filled colour palette
我正在尝试 运行 以下代码,但我似乎无法将调色板更改为 ColorBrewer 的光谱调色板。想法?
maya <- tibble(
mass = seq(1, 10, length.out = 10),
mois = seq(11, 20, length.out = 10)
) %>%
expand(mass, mois) %>%
mutate(
diff = mois - mass * runif(1)
) %>%
ggplot(aes(mass,mois,z = diff)) +
geom_contour_filled() +
scale_fill_distiller(palette = "Spectral")
maya
如果我没理解错的话,也许您正在寻找 geom_raster
与 interpolate = TRUE
和 scale_fill_distiller
的组合?
library(tidyverse)
tibble(
mass = seq(1, 10, length.out = 10),
mois = seq(11, 20, length.out = 10)
) %>%
expand(mass, mois) %>%
mutate(
diff = mois - mass * runif(1)
) %>%
ggplot(aes(mass,mois,fill = diff)) +
geom_raster(interpolate = TRUE) +
scale_fill_distiller(palette = "Spectral")
由 reprex package (v0.2.1)
于 2020-04-13 创建
要扩展,scale_fill_distiller
可以对色标进行插值以适应连续的值范围,但它实际上不能像以前那样对数据进行插值。据我所知,geom_contour_filled
中也没有内置此类功能。因此,我认为您要么需要在绘图之前手动进行插值,要么依赖于 geom_raster
.
中的插值之类的东西
我正在尝试 运行 以下代码,但我似乎无法将调色板更改为 ColorBrewer 的光谱调色板。想法?
maya <- tibble(
mass = seq(1, 10, length.out = 10),
mois = seq(11, 20, length.out = 10)
) %>%
expand(mass, mois) %>%
mutate(
diff = mois - mass * runif(1)
) %>%
ggplot(aes(mass,mois,z = diff)) +
geom_contour_filled() +
scale_fill_distiller(palette = "Spectral")
maya
如果我没理解错的话,也许您正在寻找 geom_raster
与 interpolate = TRUE
和 scale_fill_distiller
的组合?
library(tidyverse)
tibble(
mass = seq(1, 10, length.out = 10),
mois = seq(11, 20, length.out = 10)
) %>%
expand(mass, mois) %>%
mutate(
diff = mois - mass * runif(1)
) %>%
ggplot(aes(mass,mois,fill = diff)) +
geom_raster(interpolate = TRUE) +
scale_fill_distiller(palette = "Spectral")
由 reprex package (v0.2.1)
于 2020-04-13 创建要扩展,scale_fill_distiller
可以对色标进行插值以适应连续的值范围,但它实际上不能像以前那样对数据进行插值。据我所知,geom_contour_filled
中也没有内置此类功能。因此,我认为您要么需要在绘图之前手动进行插值,要么依赖于 geom_raster
.