是否可以更改geom_raster
中的插值级别(例如平滑,模糊)?
library(tidyverse)
mtcars %>%
group_by(carb, hp = cut(mtcars$hp, 3, labels = c("low", "med", "hi"))) %>%
summarise(mean_mpg = mean(mpg)) %>%
ggplot(aes(carb, hp)) +
geom_raster(aes(fill = mean_mpg), interpolate = FALSE) +
scale_fill_viridis_c(option = "inferno")
我想控制下图中发生的模糊程度:
mtcars %>%
group_by(carb, hp = cut(mtcars$hp, 3, labels = c("low", "med", "hi"))) %>%
summarise(mean_mpg = mean(mpg)) %>%
ggplot(aes(carb, hp)) +
geom_raster(aes(fill = mean_mpg), interpolate = TRUE) +
scale_fill_viridis_c(option = "inferno")
我知道如何使用stat_density_2d
- see this post执行此操作 - 但我想通过填充计算值而不是计算密度。