[R] Why is R so slow at plotting on Ubuntu 9.04?
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Sat Aug 22 18:59:14 CEST 2009
On Sat, Aug 22, 2009 at 5:52 PM, Thomas Harte<thomas.harte at yahoo.com> wrote:
> under Ubuntu 9.04 R seems to be very slow at plotting.
>
> the example below illustrates with a plot of error bars of sample means
> where i watch as each error bar is plotted one at a time. very annoying and pain in the neck when running Sweave repeatedly.
>
> running R 2.9.1 under Windoze on the same machine the error bars plotted in the code below appear instantaneously.
>
> has anyone else noticed this problem under Ubuntu 9.04?
>
> # make a load of means:
> J<- 100
> mu<- .02
> sigma<- .04
> set.seed(1)
> y.bar<- rnorm(J, mean=mu, sd=sigma)
>
> # make a load of (fake) stds about the means:
> n.j<- round(runif(J, min=10, max=100))
> sigma.alpha<- sqrt(var(y.bar) / n.j)
>
> ylim<- range(c(y.bar-2*sigma.alpha, y.bar+2*sigma.alpha))
> par(las=1)
> plot(n.j, y.bar, cex.lab=.9, cex.axis=1,
> xlab="sample size",
> ylab="some stuff",
> pch=20, log="x", cex=.5, ylim=ylim,
> )
> # HERE'S THE PROBLEM: ON UBUNTU R IS TAKING FOREVER TO PLOT THESE ERROR BARS
> for (j in 1:J) {
> lines(rep(n.j[j],2), y.bar[j] + c(-2,2)*sigma.alpha[j], lwd=1.25, col="darkgray")
> }
> abline(h=mu)
> title("Why is R so slow at plotting these error bars on Ubuntu?", cex.main=1.2, line=1)
>
>
> R version 2.9.1 (2009-06-26) i486-pc-linux-gnu
> locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages: [1] graphics grDevices utils datasets stats methods base
>
> other attached packages: [1] zoo_1.5-8 loaded via a namespace (and not attached): [1] grid_2.9.1 lattice_0.17-25
It might be the 'cairo' graphics engine. Try starting a graphics
window with X11(type="Xlib") and see if that's quicker. The default is
X11(type="cairo"), which is slower, but uses anti-aliasing to make
better quality (some say 'blurry') bitmaps.
You might also try the antialias= options for cairo graphics too -
see help(x11) for more.
Barry
More information about the R-help
mailing list