Created
December 23, 2018 07:35
-
-
Save chichacha/e8df902b78db6e6761dd9b2bc6f3b85f to your computer and use it in GitHub Desktop.
Circle Packing + Delaunay Triangulation
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
library(tidyverse) | |
library(deldir) | |
library(packcircles) | |
packing <- circleProgressiveLayout(x=runif(1000)) %>% mutate(id=row_number()) | |
data_gg <- circleLayoutVertices(packing, npoints = 36) %>% | |
inner_join(packing %>% select(id,radius), by=c("id")) | |
dxy1 <- deldir(packing$x, packing$y) | |
dxy1$delsgs %>% ggplot(aes(x=x1,y=y1)) + | |
geom_polygon(data=data_gg, aes(x=x,y=y,group=id,fill=radius), size=0.1) + | |
geom_segment(aes(xend=x2, yend=y2), size=0.9, color="#ffffffde") + | |
theme_void() + | |
coord_fixed(xlim=range(packing$x)*0.8, ylim=range(packing$y)*0.45) + | |
scale_fill_viridis_c(guide="none", option="magma", end=0.8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment