Skip to content

Instantly share code, notes, and snippets.

@chichacha
Last active January 5, 2019 20:25
Show Gist options
  • Save chichacha/9cd6c5c05402b2c98b202fd5e37e0698 to your computer and use it in GitHub Desktop.
Save chichacha/9cd6c5c05402b2c98b202fd5e37e0698 to your computer and use it in GitHub Desktop.
When a rainy day make you think of umbrella....
## There's no need to generate progressive packed circle if you want grid of things...
df <- tibble(
x = rep(c(1:10), times=10),
y = rep(c(1:10), each=10),
radius = 0.5
)
df_triangles <- circleLayoutVertices(df,npoints=8,sizetype="radius")
df_triangles_1 <- circleLayoutVertices(df %>% mutate(radius=sqrt(radius)),
npoints=8,sizetype="area")
df_triangles_2 <- circleLayoutVertices(df %>% mutate(radius=radius*rbeta(100,1,2)),
npoints=8,sizetype="area")
df_triangles %>%
ggplot(aes(x=x,y=y,group=id)) +
geom_polygon(aes(fill=id%%8)) +
geom_path(data=df_triangles_1, color="white") +
geom_path(data=df_triangles_2, color="white") +
coord_fixed() +
theme_void() +
scale_fill_viridis_c(guide="none")
library(packcircles)
library(ggthemes)
library(tidyverse)
## Actually you don't really need to this... if you are wanting grid of things.
circles <- circleProgressiveLayout(x=rep(1,1000), sizetype="radius") %>%
mutate(id=row_number(x*y)) %>% arrange(id)
circles_df <- circleLayoutVertices(circles,npoints=6) %>%
inner_join(circles %>% select(id,xc=x,yc=y,r=radius))
circles_df <- circles_df %>%
mutate(xc_id = dense_rank(round(xc,3)),yc_id=dense_rank(round(yc,3)))
circles_df %>%
ggplot(aes(x=xc,y=yc)) +
geom_path(aes(group=yc_id), size=0.1, color="white") +
geom_path(aes(group=xc_id), size=0.1, color="white") +
geom_polygon(aes(x=x,y=y,group=id, fill=factor(xc_id%%19),alpha=id%%30), size=0.1) +
theme_void() +
#coord_fixed(xlim=c(-20,20), ylim=c(-20,20)) +
coord_cartesian(xlim=c(-20,20), ylim=c(-15,15)) +
geom_path(data=. %>% arrange(x), aes(group=round(y,2)),size=0.1, color="white") +
geom_path(data=. %>% arrange(y), aes(group=round(x,2)), size=0.1, color="white") +
geom_point(aes(x=xc,y=yc),size=0.5, color="white") +
geom_point(aes(x=x,y=y), size=0.3) +
scale_fill_tableau("Hue Circle", guide="none") +
scale_alpha_continuous(range=c(0.1,0.8), guide="none")
ggsave("RainyUmbrella.png", width=20, height=15)
@chichacha
Copy link
Author

rainyumbrella

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