(This article was first published on

**Fiddling with data and code » R**, and kindly contributed to R-bloggers)I like to explore the graphics features of R. Base graphics, ggplot2 are my favourites. On other graphics packages, I haven’t used plotrix much. I am currently exploring grid package.

## Raptor

First one is using ggplot2. (you could also do this using base graphics).

## ##reading raptor cordinates rapt = read.csv("http://vinux.in/viz/misc/raptor.csv") library(ggplot2) ggplot(data=rapt) + geom_polygon(aes(x=V1, y=V2, group=group), colour=I("gray") ) + theme_bw() + scale_x_continuous(limits = c(0, 400)) + scale_y_continuous(limits = c(0, 250)) + geom_text(aes(100,230, label="Velociraptor"))+ theme(axis.line=element_blank(), axis.text.x=element_blank(), axis.text.y=element_blank(), axis.ticks=element_blank(), axis.title.x=element_blank(), axis.title.y=element_blank(), legend.position="none", panel.background=element_blank(), panel.border=element_blank(), panel.grid.major=element_blank(), panel.grid.minor=element_blank(), plot.background=element_blank())

It would be more fun if we can do animation on raptors. You can find animated version of raptor here. Rcode.

**Cake**

Here is the easy one. This one is a cake using plotrix package.

## library(plotrix) candle = function(pos) { x=pos[1] y=pos[2] rect(x,y,x+.2,y+2,col="red") # polygon(c(x-.2,x+.4,x+.1,x-.2), c(y+2,y+2,y+2.4,y+2),col="orange") polygon(c(x+.05,x-.1,x+.1,x+.3,x+.15,x+0.05), c(y+2,y+2.3,y+2.6,y+2.3,y+2,y+2),col="orange") } cake_colour="#FF3399" plot(c(0,10), c(0,10),type="n", bty="n",xaxt="n",yaxt="n", main="Cake", xlab="",ylab="") draw.ellipse(5,2,col=cake_colour,a=4.4,b=1.7,border=1) draw.ellipse(5,2,col=cake_colour,a=4,b=1.4,border=1) rect(1,2,9,5,col=cake_colour,border=cake_colour) lines(c(1,1),c(2,5)) lines(c(9,9),c(2,5)) draw.ellipse(5,5,col=cake_colour,a=4,b=1.4) candle(c(2.5,4.5)) candle(c(3,5)) candle(c(4,4.5)) candle(c(5,5)) candle(c(6,4.5)) candle(c(7,5.2))

I have already discussed this graphs in my favourite forum talkstats. I dedicated both the graphs to my friends in the forum. You can find more fun graphs in this forum.

The post Fun with R graphics: A raptor and a cake appeared first on Fiddling with data and code.

To

**leave a comment**for the author, please follow the link and comment on his blog:**Fiddling with data and code » R**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...