[R] lattice and display

Deepayan Sarkar deepayan at stat.wisc.edu
Thu Dec 19 18:42:03 CET 2002


On Thursday 19 December 2002 08:33 am, Nolwenn Le Meur wrote:
> Hi,
>
> I have just started using lattice and it looks great. But I already have 3
> questions about xyplot display.
> ---------------------------------------------------------------------------
>- ---------------------------------
> 1.I would like to create two differeny xyplot with different color to
> identify my different groups but I have trouble applying colors.
> Here are the scripts
>
>  xyplot(resultdata$Y~resultdata$X ,
> data=resultdata,groups=resultdata$Block, panel="panel.xyplot",
>  panel.groups="panel.xyplot",
>  xlab="X",ylab="Y",pch="*",
>  col.groups=trellis.par.get("superpose.symbol")$col[1:6],cex=2,
>  key=list(space="right",
>  points=list(pch="*",
> 	     col=trellis.par.get("superpose.symbol")$col[1:6]),
>  text=list(paste("Block",1:6)))
>  )

This is supposed to be called like


xyplot(Y~X, data = resultdata, 
       groups = Block, 
       xlab="X", ylab="Y",
       pch="*",
       key=list(space="right",
                points=list(pch="*",
 	        col=trellis.par.get("superpose.symbol")$col[1:6]),
                text=list(paste("Block",1:6))))

There's no argument called col.groups, and the panel function you meant to use 
was panel.superpose, not panel.xyplot (which you don't have to specify 
explicitly since it's the default).

> xyplot(resultdata$Y~resultdata$X |resultdata$Block, data=resultdata,
>  xlab="X",ylab="Y",
> col.groups=trellis.par.get("superpose.symbol")$col[1:6],cex=2,
>  key=list(space="right",
>  points=list(pch=trellis.par.get("superpose.symbol")$pch[1:6],
> 	     col=trellis.par.get("superpose.symbol")$col[1:6]),
>  text=list(paste("Block",1:6)))
>  )

What exactly are you trying to do here? You don't have a grouping factor, so 
why is just 

xyplot(Y ~ X | Block, data = resultdata, 
       xlab="X", ylab="Y", cex = 2)

not OK ?


> ---------------------------------------------------------------------------
>- -------------------------------
>
> 2.For the latest formula I would also like to change the resultdata$Block
> label by the corresponding "Block x".

I'm not sure what you mean. If you are talking about the Labels in the strip 
above each panel, that would come from the levels of the Block variable. So, 
the Block variable has to be a factor, and it should have levels "Block 1" 
... "Block 6". See ?factor for how to do that.


> ---------------------------------------------------------------------------
>- -------------------------------
>
> 3.I finally would like to save my plot as "jpg" files under Linux but I
> loose the color.

How did you try to do this ?

Deepayan




More information about the R-help mailing list