SVG plots
Wednesday, January 28th, 2009Michael suggested that I tried out SVG images instead of antialiasing PNG images for my graphs here.
Well, here goes:
PNG file:
SVG file:
–
28-46=-18
Michael suggested that I tried out SVG images instead of antialiasing PNG images for my graphs here.
Well, here goes:
–
28-46=-18
Okay, with Widmann’s help I now see my plots unscaled, so now I can actually see the difference between the graphs with and without antialiasing. Below, I’ll show the graphs from the SQL experiments, with and without:




Now this time I think it is a massive improvement!
–
26-42=-16
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…
–
25-41=-16