我在 R 中使用 ambient
包来生成图表。它提供了一个自定义的基本绘图方法。
library(ambient)
library(dplyr)
grid <- long_grid(x = seq(0, 1, length.out = 1000),
y = seq(0, 1, length.out = 1000))
grid <- grid %>%
mutate(
noise = fracture(gen_perlin, fbm, octaves = 4, x = x, y = y, freq_init = 5)
)
plot(grid, noise)
但是我想使用 ggplot2
和 geom_raster
而不是基础绘图来绘制此图像。我试着做
ggplot(grid, aes(x = x, y = y, color = noise)) +
geom_raster()
但那只是产生
知道如何用 ggplot2 制作这个吗?