In my recent post on spatial SQL queries, I included plots showing the results of my performace tests. I wanted to show the results, and a graph is good for that, but I wasn’t completely happy with the graphics. Mainly because they lack antialiasing.
I plotted the graphs using R and refuse to believe that R can not do a better job at it.
So a bit of googling tells me that indeed R can. If I use the Cairo package for plotting.
With the plain old plotting to png, using some random points for a plot:
x <- seq(-100,100,length.out=100) y <- sapply(x, function (z) rnorm(1,z,abs(z))) png('old-style.png') plot(x, y, main='Test plot', pch=21, col='blue', bg='lightblue') abline(lm(y ~ x), col='red', lwd=2) dev.off()
I get a result like this:
Well, installing Cairo and plotting
install.packages(c("Cairo"), repos="http://cran.r-project.org" ) library(Cairo) CairoPNG('new-style.png') plot(x, y, main='Test plot', pch=21, col='blue', bg='lightblue') abline(lm(y ~ x), col='red', lwd=2) dev.off()
gives me this:
I was hoping for more of an improvement. It is a little better, but it still looks a bit ugly on the webpage.
The improvement when I look in an image viewer is great, but the rendering here isn’t improved much.
So I’m back to looking for ways to get better graphics on my blog…