本文主要是介绍【R语言可视化】R语言画爱心图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
数学系也可以很浪漫~~
rm(list=ls())
library(grid)heart <- function(lcolor){t=seq(0, 2*pi, by=0.1)x=16*sin(t)^3y=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))grid.lines(a,b,gp=gpar(col=lcolor,lty = "solid",lwd = 3))
}vp <- viewport(.10, .15, w=.3, h=.6)
grid.newpage()
vp1 <- viewport(.4, .5, w=.5, h=.5,angle=15)
pushViewport(vp1)
heart("red")
vp2 <- viewport(0.9, .27, w=.7, h=.7,angle=-30)
pushViewport(vp2)
heart("hotpink")
grid.text("尝试了七十七次,才找到了自己想跟你分享的图案。",x=0.2,y =1.2, just = c("center", "bottom"),gp = gpar(fontsize=20), vp = vp)
这篇关于【R语言可视化】R语言画爱心图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!