Paul Johnson wrote:

I have a linux system with Fedora Core 2 and R-2.0.

I was comparing plots made with plot() and dotplot() and discovered a problem. Although the dots are positioned correctly, the numerical labels in the dotplot y axis are not correct.

I put copies here:

http://lark.cc.ku.edu/~pauljohn/R/plotTrouble1.jpg

That is the "correct" one from plot, with the higest value on y showing at 18.

http://lark.cc.ku.edu/~pauljohn/R/plotTrouble2.jpg

That is the dotplot one. The picture is basically the same, except the numbers on the y axis only go up to 8. But the dots are in the correct spots and the x axis is labeled correctly.

On the screen, the plots have white backgrounds, but the picture from the dotplot turns out gray. Why is that? Sometimes, if I run another lattice plot in the same session, the colors change to the dark background, and I suppose the same trouble is happening. Isn't trellis.par.set() going to remain in place for all following trellis plots?


Here's the code I used to make these 2 graphs.

x11(height=6.5,width=6.5)
data2003<- subset(elaine1,POLCYEAR==2003)
plot(data2003$OLDCRASH,data2003$RENUCYC)

modall <- lm(RENUCYC~OLDCRASH,data=data2003)
abline(modall)

dev.copy(device=jpeg,file="plotTrouble1.jpg")
dev.off()
dev.off()

trellis.par.set(theme=col.whitebg(),height=9,width=6.5)
dotplot (RENUCYC~OLDCRASH, data=elaine1, xlab="ECR", as.table=T,subset=POLCYEAR==2003,
panel=function(x,y)
{
panel.dotplot(x,y,cex=0.2);
panel.lmline(x,y);
}
)


jpeg(file="plotTrouble2.jpg",bg="white",height=480,width=480)
trellis.last.object()
dev.off()
dev.off()


I tried to force the ylim on the dotplot up to 18, but it just produced this even uglier result.


http://lark.cc.ku.edu/~pauljohn/R/plotTrouble3.jpg


Paul,

dotplot is not doing what you think it's doing. RENUCYC is being forced to a factor with 9 levels. I think what you intending to use is xyplot. Just

trellis.par.set(theme=col.whitebg(),height=9,width=6.5)
xyplot(RENUCYC~OLDCRASH, data=elaine1, xlab="ECR",
       as.table=T,subset=POLCYEAR==2003,
       panel=function(x,y) {
         panel.dotplot(x,y,cex=0.2) #; no need for semi-colons
         panel.lmline(x,y)
       })

As for your second question, when you call jpeg a new device is called. You need to reset the theme after opening the device, or just use trellis.device:

trellis.device(jpeg, file="plotTrouble2.jpg",
               theme = col.whitebg(),height=480,width=480)
trellis.last.object()
dev.off()


--sundar

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to