[R] dotplot & lattice problems: y axis values and bg color output in jpg

Paul Johnson pauljohn at ku.edu
Sat Oct 23 00:16:37 CEST 2004


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 E. Johnson                       email: pauljohn at ku.edu
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
1541 Lilac Lane, Rm 504
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66044-3177           FAX: (785) 864-5700




More information about the R-help mailing list