I hope everyone’s wishes come true!!! I wish happiness and health to all of you!!
And this is the code to reproduce this image in R
The code:
[sourcecode language=”r”]
#plot the base layer
par(bg = sample(colorpalette,1))
plot(0:10,0:10,type="n",xlab="",ylab="",xaxt="n",yaxt="n")
#create color palette
colorpalette <- c("yellow","brown","orange","chocolate","coral",
"red","magenta","pink","blue",
"purple","darkgoldenrod2","darkkhaki",
"gold4","olivedrab1","palegreen","steelblue1",
"lightgreen")
#merry x-mas
points(0,10,pch="m",cex=4,col=sample(colorpalette,1))
points(1,10,pch="e",cex=4,col=sample(colorpalette,1))
points(2,10,pch="r",cex=4,col=sample(colorpalette,1))
points(3,10,pch="r",cex=4,col=sample(colorpalette,1))
points(4,10,pch="y",cex=4,col=sample(colorpalette,1))
points(6,10,pch="x",cex=4,col=sample(colorpalette,1))
points(7,10,pch="-",cex=4,col=sample(colorpalette,1))
points(8,10,pch="m",cex=4,col=sample(colorpalette,1))
points(9,10,pch="a",cex=4,col=sample(colorpalette,1))
points(10,10,pch="s",cex=4,col=sample(colorpalette,1))
#happy 2014
points(0,9,pch="H",cex=4,col=sample(colorpalette,1))
points(1,9,pch="A",cex=4,col=sample(colorpalette,1))
points(2,9,pch="P",cex=4,col=sample(colorpalette,1))
points(3,9,pch="P",cex=4,col=sample(colorpalette,1))
points(4,9,pch="Y",cex=4,col=sample(colorpalette,1))
points(6,9,pch="2",cex=4,col=sample(colorpalette,1))
points(7,9,pch="0",cex=4,col=sample(colorpalette,1))
points(8,9,pch="1",cex=4,col=sample(colorpalette,1))
points(9,9,pch="4",cex=4,col=sample(colorpalette,1))
#Make the tree
rect(4.5,0,5.5,2,col="brown",border="brown")
#start from bottom to top
polygon(c(2,5,8),c(2,5,2),col="palegreen4",border="palegreen4")
polygon(c(2.5,5,7.5),c(4,7,4),col="green",border="green")
polygon(c(3,5,7),c(6,8,6),col="palegreen3",border="palegreen3")
#make the star
points(5,8,pch=8,cex=12,col="gold",lwd=6)
#make the tree balls
points(2,2,pch=20,cex=4,col=sample(colorpalette,1))
points(8,2,pch=20,cex=4,col=sample(colorpalette,1))
points(2.5,4,pch=20,cex=3,col=sample(colorpalette,1))
points(7.5,4,pch=20,cex=3,col=sample(colorpalette,1))
points(3,6,pch=20,cex=2,col=sample(colorpalette,1))
points(7,6,pch=20,cex=2,col=sample(colorpalette,1))
#decorate first triangle
points(3,2,pch=sample(15:20,1),cex=4,col=sample(colorpalette,1))
points(5,2,pch=sample(15:20,1),cex=4,col=sample(colorpalette,1))
points(7,2,pch=sample(15:20,1),cex=4,col=sample(colorpalette,1))
points(4.5,3,pch=sample(15:20,1),cex=4,col=sample(colorpalette,1))
points(5.5,3,pch=sample(15:20,1),cex=4,col=sample(colorpalette,1))
#decorate second triangle
points(4,4,pch=sample(15:20,1),cex=3,col=sample(colorpalette,1))
points(5,4,pch=sample(15:20,1),cex=3,col=sample(colorpalette,1))
points(6,4,pch=sample(15:20,1),cex=3,col=sample(colorpalette,1))
points(4.5,5,pch=sample(15:20,1),cex=3,col=sample(colorpalette,1))
points(5.5,5,pch=sample(15:20,1),cex=3,col=sample(colorpalette,1))
#decorate third triangle
points(4,6,pch=sample(15:20,1),cex=2,col=sample(colorpalette,1))
points(5,6,pch=sample(15:20,1),cex=2,col=sample(colorpalette,1))
points(6,6,pch=16,cex=3,col=sample(colorpalette,1))
points(4.5,7,pch=16,cex=3,col=sample(colorpalette,1))
points(5.5,7,pch=16,cex=3,col=sample(colorpalette,1))
[/sourcecode]
Leave a Reply