title: "Testing gistr package" author: "Chisato" date: "27/07/2019" output: html_document: highlight: kate theme: spacelab
This file contains hidden or 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(magick) | |
library(imager) | |
library(ggvoronoi) | |
library(TSP) | |
create_char_image <- function(char="美"){ | |
data.frame() %>% | |
ggplot(aes(x=0,y=0)) + |
This file contains hidden or 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) | |
#half_circle | |
half_circle <- function(xc=0,yc=0,r=1,shift=0,points=100,...){ | |
df <- tibble( | |
t = seq(shift ,pi+shift,length.out=points), | |
x = xc + r*cos(t), | |
y = yc + r*sin(t) | |
) | |
return(df %>% select(x,y)) |
This file contains hidden or 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(scales) | |
phi <- (1 + sqrt(5))/2 | |
draw_rect <- function(xr=1,yr=1,name="square") { | |
df <- tibble( | |
x=c(0,0,xr,xr,0), | |
y=c(0,yr,yr,0,0) | |
) |
This file contains hidden or 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
make_params <- function(n=60){ | |
params <- tibble( | |
x1 = runif(n), | |
x2 = runif(n), | |
y1 = runif(n), | |
y2 = runif(n) | |
) %>% mutate(g=row_number()) | |
} |
This file contains hidden or 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
## drawing heart! | |
library(tidyverse) | |
library(gganimate) | |
## function to create data frame for heart shape with 100 points. | |
heart_vertices <- function(xc=0,yc=0,npoints=100,...){ | |
t = seq(-pi,pi, length.out=npoints+1) | |
x = xc + 16 *(sin(t))^3 | |
y = yc + 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t) |
This file contains hidden or 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) | |
## creating raster to use as background | |
## get your favourite colour | |
colpal <- c("#fe4a49", "#2ab7ca", "#fed766", "#e6e6ea", "#f4f4f8") | |
viridis_bg <- matrix(viridis_pal()(150*50),nrow=50) |
This file contains hidden or 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) | |
df <- tibble() %>% | |
expand(x=c(0:32), y=c(0:16)) | |
df %>% | |
sample_n(nrow(df)-1) %>% | |
ggplot(aes(x=x,y=y)) + |
This file contains hidden or 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) | |
my_points <- tibble( | |
x = c(1,4,4,0,0,4,4,1,1,2.5,0,0,0,2.5,1,0), | |
y = c(0,0,2,2,5,5,7,7,0,0,5,2,2,7,7,5), | |
g = c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4) | |
) | |
my_points2 <- my_points %>% |
This file contains hidden or 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(tidytext) | |
library(ggforce) | |
library(patchwork) | |
library(ggthemes) | |
## prep colour palettes | |
hue_circle <- ggthemes::tableau_color_pal("Hue Circle")(16) |