Created
April 1, 2020 10:36
-
-
Save marcusvolz/4950857b0bb11c61a0079bba75049dfc to your computer and use it in GitHub Desktop.
Procedural ring generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load packages | |
library(generative) # install_github("marcusvolz/generative") | |
library(tidyverse) | |
# Create lots of plots | |
for (i in 1:200) { | |
# Set paramter values | |
set.seed(i) | |
r_0 <- runif(1, 0, 1000) # 15000 | |
eps <- runif(1, 0, 500) # 550 | |
eps_big <- r_0 + runif(1, 0, 1500) # 7000 | |
p_defect = runif(1, 0, 0.1) # 0.09 | |
delta <- runif(1, 0, 5) | |
# Generate data | |
df <- procedural_ring(seed = i, n = 400, n_circles = 4, r_0 = r_0, eps = eps, eps_big = eps_big, p_defect = p_defect, delta = delta) | |
# Create plot | |
p <- ggplot() + | |
geom_segment(aes(x, y, xend = xend, yend = yend), df, size = 0.025, alpha = 0.05) + | |
coord_equal() + | |
theme_void() | |
# Save plot | |
ggsave(paste0("procedural_ring_", sprintf("%03.0f", i), ".png"), p, width = 20, height = 20, units = "cm") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment