logo头像

还想什么呢,做就是了

R|ggplot2-想女朋友了,这么做不过分吧?

ggplot2心形图

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
library(ggplot2)
library(ggthemes)
#建立笛卡尔心形函数所需要的数据heartd
t=seq(0,2*pi,by=0.1)
x=16*sin(t)^3
y=13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)
a=(x-min(x))/(max(x)-min(x))
b=(y-min(y))/(max(y)-min(y))
heartd <- data.frame(t,x,y,a,b)
#使用ggplot的路径图画出心形
ggplot(heartd,aes(a,b))+geom_polygon(fill="pink")
+theme_map()+labs(title="送给可爱的程百卉")
+theme(plot.title=element_text(hjust=0.5,color="red",size=28))
+annotate("text",label="你像电池\n我像手机\n
没有你就没有我的全世界",size=10,color="red",x=0.5,y=0.6)

支付宝打赏 微信打赏

赞赏是不耍流氓的鼓励

评论系统未开启,无法评论!