[R] Bug in Cairo?

Lorenzo Isella lorenzo.isella at gmail.com
Thu Mar 11 19:21:10 CET 2010


Dear All,
I am not really an expert about visualization and plotting, but consider 
the code snippet at the end of this email.
On my machine ((X)Ubuntu for the amd64 bit architecture, Cairo installed 
from Cran, R 2.10),  the two plots (one with R basic graphics, the other 
generated using Cairo) do look pretty different.
To be precise, the one by Cairo seems to have a few misplaced characters 
and also the size of the axis label looks different from those in the 
plot I generate via pdf().
I posted something along these lines on the ggplot2 list (I thought this 
had something to do with the ggplot2 library at the time) and I was told 
that these problems are about to disappear with the next R release.
Can anyone else running R 2.11 confirm this? Is anyone else experiencing 
these minor glitches in Cairo?
Many thanks

Lorenzo



###################################################
####################################################
#####################################################



rm(list=ls())

library(ggplot2)
library(Cairo)

set.seed(1234)

time <- seq(0,40,length=200)

delta <- runif(200,-2e-3,1e-3)
delta_2 <- runif(200,-2e-3,1e-3)

pdf("test_cairo.pdf")

par( mar = c(4.5,5, 2, 1) + 0.1)

plot(time, delta,col="blue","p",lwd=2,lty=1,pch=1,xlab = "Dimensionless 
time t",
     
ylab=expression(paste("(",R[g],"[0]-",R[g],"[t])/",R[g],"[0]")),cex.axis=1.4,cex.lab=1.6,
     ylim=range(c(-2e-3,1e-3)),yaxt="n")
lines(time, delta_2, "p",col="red",lwd=2,lty=1,pch=5 )
axis(side=2, at=c(-2e-3,-1e-3,0,1e-3),
labels=expression(-2%*%10^-3, -1%*%10^-3,0, 
1%*%10^-3),cex.lab=1.4,cex.axis=1.4)
legend("bottomleft",cex=1.2,c(expression(paste(Delta,"t")),expression(paste(Delta,"t/4") 
))
,lwd=c(2,2), lty=c(-1,-1),pch = c(1,5),col=c("blue", "red")
,xjust = 1, yjust = 1
       ,box.lwd=0,box.lty=0)

dev.off()


CairoPDF("test_cairo_2.pdf")

par( mar = c(4.5,5, 2, 1) + 0.1)

plot(time, delta,col="blue","p",lwd=2,lty=1,pch=1,xlab = "Dimensionless 
time t",
     
ylab=expression(paste("(",R[g],"[0]-",R[g],"[t])/",R[g],"[0]")),cex.axis=1.4,cex.lab=1.6,
     ylim=range(c(-2e-3,1e-3)),yaxt="n")
lines(time, delta_2, "p",col="red",lwd=2,lty=1,pch=5 )
axis(side=2, at=c(-2e-3,-1e-3,0,1e-3),
labels=expression(-2%*%10^-3, -1%*%10^-3,0, 
1%*%10^-3),cex.lab=1.4,cex.axis=1.4)
legend("bottomleft",cex=1.2,c(expression(paste(Delta,"t")),expression(paste(Delta,"t/4") 
))
,lwd=c(2,2), lty=c(-1,-1),pch = c(1,5),col=c("blue", "red")
,xjust = 1, yjust = 1
       ,box.lwd=0,box.lty=0)

dev.off()



More information about the R-help mailing list