Submitted by dylan on Wed, 2007-09-26 22:15.
The Cairo package for R is a fully functional replacement for X11, PNG, PDF, Postscript, etc. output devices, based on the Cairo 2D rendering engine. The generic Cairo() function can be used to create high quality raster and vector output, with support for anti-aliasing and transparent colors.
Example Code:
## load libraries
library(Cairo)
## start the output file
Cairo(file="cairo_test.png", type='png', bg='white', width=400, height=400)
## generate 3 clusters of points
x1 <- rnorm(100, 3, 1.5)
y1 <- rnorm(100, 3, 1.5)
x2 <- rnorm(100, -5, 1)
y2 <- rnorm(100, -5, 1)
x3 <- rnorm(100, -5, 2)
y3 <- rnorm(100, 5, 2)
## plot the clusters
## note that the colors are RGBA triplets
## the last 2 characters are the alpha channel value (transparency)
plot(x1,y1, col="#ff000018",pch=19,cex=2, xlim=c(-10,10), ylim=c(-10,10), xlab='x', ylab='y', main='Cairo Test')
points(x2,y2, col="#00ff0018",pch=19,cex=1)
points(x3,y3, col="#0000ff10",pch=19,cex=3)
## close the output file
dev.off()
Example Cairo Output from R: Simple plotting with transparency and anti-aliased lines.