[R] Why is R so slow at plotting on Ubuntu 9.04?

Thomas Harte thomas.harte at yahoo.com
Sat Aug 22 18:52:24 CEST 2009


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




More information about the R-help mailing list