Last active
August 12, 2019 04:27
-
-
Save chichacha/fcd5dc852f63c3859b34591f8a6abaa6 to your computer and use it in GitHub Desktop.
Simple Example of geom_bspline_closed function in ggforce
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(ggforce) | |
library(patchwork) | |
library(ggthemes) | |
df <- tibble( | |
t = seq(0,2*pi,length.out=61) | |
) %>% mutate(idx=row_number(), | |
m = sqrt((idx%%2)+0.1), | |
x = m*cos(t), | |
y = m*sin(t)) | |
df %>% | |
filter(idx<nrow(df)) %>% | |
ggplot(aes(x=x,y=y,group=idx%%3)) + | |
geom_bspline_closed(radius=unit(2,"mm"), aes(fill=idx%%3), n=20) + | |
geom_bspline_closed(expand=unit(2,"mm"), aes(fill=idx%%3), n=20) + | |
coord_fixed() + | |
theme_void() + | |
scale_fill_viridis_c(alpha=0.3, end=0.8, option="magma", guide="none") | |
df %>% | |
filter(idx<nrow(df)) %>% | |
ggplot(aes(x=x,y=y)) + | |
geom_bspline_closed(radius=unit(2,"mm"), n=1000, alpha=0.2) + | |
geom_bspline_closed(expand=unit(-2,"mm"), n=1000, alpha=0.8) + | |
coord_fixed() + | |
theme_void() + | |
scale_fill_viridis_c(alpha=0.3, end=0.8, option="magma", guide="none") + | |
geom_point(size=0.5) + | |
geom_path(size=0.2) + | |
geom_shape(size=0.3, expand=unit(-2,"mm")) |
Author
chichacha
commented
Aug 12, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment