事情起因是这样的:在某个搞技群里有人发了一个11维的蜜汁微笑矩阵用来逼死密集恐惧症——
11*11蜜汁微笑矩阵
于是有人用一个[擦汗]的表情表示无语……
可是仅仅一个表情,怎么能以对等的气势怼回去呢?于是——
- emoji = '[擦汗]'
- for i in range(11):
- print(emoji*(i+1))
11维下三角擦汗
不过考虑到这种方法只能把表情按离散整数的序列来放置,还不能在任意的连续数值处放表情。考虑到R中的ggimage包可以用图片来代替散点,于是一个思路就是画散点(曲线)图,然后用表情来代换散点。
然后,升级版的逼死密集恐惧症图形就新鲜出炉了——
正弦式笑哭
- library(ggplot2)
- library(ggimage)
- showtext::showtext.auto(enable = T)
- theme1 <- theme(panel.background = element_rect(fill = "black",color = "black"),plot.background = element_rect(fill="black",color = "black"),panel.grid = element_blank(),plot.title = element_text(hjust=0.5,family = "SimHei",size = 24,color = "#FEFEFE"),
- axis.text = element_blank(),axis.ticks = element_blank())
- # 正弦曲线
- x <- seq(from=0,to=2*pi,length.out = 80)
- y <- sin(x)
- df_sin <- data.frame(x = x,y=y)
- ggplot(df_sin,aes(x,y))+
- geom_emoji(aes(image='1f602'))+
- labs(x= "",y="",title="正弦式笑哭")+
- theme1
逻辑回归式笑哭
- # sigmoid曲线
- sigmoid <- function(x) return(1/(1+exp(-x)))
- x <- seq(from=-10,to=10,length.out = 100)
- y <- sigmoid(x)
- df_sigmoide <- data.frame(x = x,y=y)
- ggplot(df_sigmoide,aes(x,y))+
- geom_emoji(aes(image='1f602'))+
- labs(x= "",y="",title="逻辑回归式笑哭")+
- theme1
正态分布式笑哭
- # 正态密度曲线
- x <- seq(-5,5,length.out = 100)
- y <- dnorm(x)
- df_norm <- data.frame(x = x,y=y)
- ggplot(df_norm,aes(x,y))+
- geom_emoji(aes(image='1f602'))+
- labs(x= "",y="",title="正态分布式笑哭")+
- theme1
爱心式笑哭
- # 心形曲线
- t <- seq(0,2*pi,length.out = 100)
- x <- 16*(sin(t)^3)
- y <- 13*cos(t) - 5*cos(2*t) - 2*cos(3*t)-cos(4*t)
- df_heart <- data.frame(x=x,y=y)
- ggplot(df_heart,aes(x=x,y=y))+
- geom_emoji(aes(image='1f602'))+
- labs(x= "",y="",title="爱心式笑哭")+
- theme1
众星捧月式笑哭
- # 弧形
- x <- seq(-10,10,length.out=40)
- r <- 10
- y <- -sqrt(r^2-x^2)
- df_cirle <- data.frame(x = c(x,0), y = c(y,5),z=2)
- df_cirle$z[nrow(df_cirle)] <- 16
- ggplot()+
- geom_emoji(data=df_cirle,mapping=aes(x=x,y=y,image='1f602',size=z))+
- scale_y_continuous(limits = c(-10,12))+
- scale_size_area(max_size = 0.3)+
- labs(x= "",y="",title="众星捧月式笑哭")+
- guides(size=F)+
- theme1
囧式笑器
- x <- seq(-10,10,length.out = 100)
- y <- 2/(x^2-2)
- shift <- 3
- x1 <- rep(seq(min(x)-shift,max(x)+shift,length.out = 150),2)
- y1 <- c(rep(min(y)-shift,150),rep(max(y)+shift,150))
- x2 <- c(rep(min(x)-shift,150),rep(max(x)+shift,150))
- y2 <- rep(seq(min(y)-shift,max(y)+shift,length.out = 150),2)
- df_orz <- data.frame(x=c(x,x1,x2),y=c(y,y1,y2))
- ggplot(df_orz,aes(x=x,y=y))+
- geom_emoji(aes(image='1f602'))+
- labs(x= "",y="",title="囧式笑哭")+
- theme1
金拱门式笑哭
- # 金拱门
- x <- seq(0,2*pi,length.out = 100)
- y <- abs(sin(x))
- df_m <- data.frame(x=x,y=y)
- ggplot(df_m,aes(x=x,y=y))+
- geom_emoji(aes(image='1f602'))+
- labs(x= "",y="",title="金拱门式笑哭")+
- theme1
四叶草式笑哭
- # 四叶草
- x <- seq(0,2*pi,length.out = 100)
- y <- cos(4*x)
- df_flower <- data.frame(x=x,y=y)
- ggplot(df_flower,aes(x,y))+
- geom_line()+
- geom_emoji(aes(image='1f602'))+
- coord_polar()+
- labs(x= "",y="",title="四叶草式笑哭")+
- theme1
万花筒式笑哭
- # 万花筒式笑哭
- get_circle <- function(r){
- t <- seq(-r,r,length.out = 50*sqrt(r))
- x <- rep(t,2)
- y <- c(sqrt(r^2-t^2),-sqrt(r^2-t^2))
- df <- data.frame(x=x,y=y)
- return(df)
- }
- df_circle <- data.frame(x=NULL,y=NULL)
- layer <- 11
- for(i in 1:layer){
- df_circle <- rbind(df_circle,get_circle(i))
- }
- ggplot()+
- geom_emoji(data = df_circle,aes(x,y,image='1f602'))+
- scale_x_continuous(limits = c(-layer,layer))+
- labs(x= "",y="",title="万花筒式笑哭")+
- theme1
无招胜有招式笑哭
- # 无招胜有招式笑哭
- x <- rnorm(10000,mean=0,sd=10)
- y <- rnorm(10000,mean = 0,sd=10)
- df_norm <- data.frame(x=x,y=y)
- ggplot(data = df_norm,mapping = aes(x,y,image='1f602'))+
- geom_emoji()+
- labs(x= "",y="",title="无招胜有招式笑哭")+
- theme1