关于 r:geom_contour_filled 调色板

geom_contour_filled colour palette

我试图运行以下代码,但似乎无法将调色板更改为 ColorBrewer 的 Spectral 调色板。想法?

1
2
3
4
5
6
7
8
9
10
11
12
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_rasterinterpolate = TRUEscale_fill_distiller 的组合?

1
2
3
4
5
6
7
8
9
10
11
12
13
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")

></p>
<p>由 reprex 包 (v0.2.1) 创建于 2020-04-13</p>
<p><center> <script src=

为了扩展,scale_fill_distiller 可以插入色标以适应连续范围的值,但实际上它不能像原来那样插入您的数据。据我所知, geom_contour_filled 也没有内置这样的功能。因此,我认为您要么需要在绘图之前手动进行插值,要么依赖于 geom_raster.

中的插值之类的东西