Skip to content

Instantly share code, notes, and snippets.

@chichacha
Created February 8, 2019 07:15
Show Gist options
  • Save chichacha/73cbdc386da337ccb212fd47b627689f to your computer and use it in GitHub Desktop.
Save chichacha/73cbdc386da337ccb212fd47b627689f to your computer and use it in GitHub Desktop.
Chaos but not chaos
make_params <- function(n=60){
params <- tibble(
x1 = runif(n),
x2 = runif(n),
y1 = runif(n),
y2 = runif(n)
) %>% mutate(g=row_number())
}
make_midpoints <- function(x1,x2,y1,y2,g,n=10){
midpoints <- tibble(
x = x1 + ((x2-x1) * c(1:n)/n),
y = y1 + ((y2-y1) * c(1:n)/n),
g = g,
dist = sqrt((x2-x1)^2 + (y2-y1)^2)
) %>%
mutate(g_idx = sample(row_number()), noise=rbeta(n,1,5))
return(midpoints)
}
metropolis <-make_params(30) %>% pmap_df(make_midpoints,n=12)
metropolis %>%
ggplot(aes(x=x,y=y, color=g)) +
geom_point(aes(size=dist+noise, alpha=dist)) +
geom_path(aes(group=g), size=0.1) +
theme_void() +
scale_alpha_continuous(range=c(0.5,0.8), guide="none") +
scale_size_continuous(range=c(0.1,10), guide="none") +
scale_color_gradientn(guide="none",
colours=sample(ggthemes::tableau_color_pal("Hue Circle")(19)))
@chichacha
Copy link
Author

chaos_but_not_chaos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment