library(tidyverse)
library(ambient)
grid <- long_grid(
x= 1:100,
y= 1:100
)
noise <- gen_cubic(
grid$x,
grid$y,
frequency = 0.11,
fractal = 'billow',
octaves = 55,
lacunarity = 5,
gain = 0.8,
pertubation = 'fractal',
pertubation_amplitude = 5.61,
seed = 42
)
plot(noise)
tmp <- data.frame(
x=1:length(noise),
y=noise
)
tmp %>%
ggplot()+
geom_density2d(aes(x=x, y=y), )+
coord_cartesian(xlim = c(-100, 10100))
density <- MASS::kde2d(x= 1:length(noise), y= noise, n=2500)
density_df <- density$z %>%
data.frame() %>%
mutate(id = row_number()) %>%
pivot_longer(cols = -c(id), names_to = "x", names_prefix=("X")) %>%
mutate(
x = as.numeric(x),
value = as.numeric(value),
level = round(value*100000000)
)
quantile(density$value, probs = c(0.1, 0.5, 1, 2, 5, 10, 50, NA)/100)
# Initial test
pal <- colorRampPalette(c(
"black",
"#FCB76D",
"#FCB76D",
"#FCB76D",
"#AC78BA",
"#5B3758",
"black",
"#008F9B",
"#008F9B",
"#008F9B"
)
)
#alpha = 0.15
# 1000 X 1092
# pal (256)
ggplot()+
# geom_raster(
# data = density_df,
# aes(x=x, y=id, fill = value)
# )+
geom_polygon(
data = density_df,
aes(x=x,y=id, group = level, fill = level),
alpha = .15,
color = NA)+
theme_canvas("black")+
scale_fill_gradientn(colors = pal(256))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.