R graphics is something I always explore or experiment with. 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).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
## ##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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
## 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.

Hi

Very nice post. Just wondering: how did you get the raptor coordinates please?

Best,

Getting raptor cordinates is not difficult.

I had an eps image of a raptor in my collection. I extracted the cordinated from eps and tweaked a bit.

Thanks for the quick reply. Did you extract the coords in R or other tools? I am very interested. Hope you don’t mind telling me how you did that.

Thanks,

Open the eps image in notepad you can find the co-ordinates. I made it an array using R. If you want to replicate it I can send you the eps image to your email id.

That will be great if you can send me via email the eps image. Thanks a lot!

Cheers,

Done.

A blog post on altering eps images and reading into R would be nice.

I will do it next time. The problem is not all eps is in smooth form. So, I cannot genralize my regular expression.