[R] lattice color problem with symbols: bug?

Deepayan Sarkar deepayan.sarkar at gmail.com
Fri Jan 11 22:12:03 CET 2008

On 1/11/08, Stefan Grosse <singularitaet at gmx.net> wrote:
> Dear useR's,
> I have a problem with the lattice plotting of some symbols:
> library(lattice)
> test<-data.frame(x=c(2,3,1,5),u=c(rep(1,2),rep(2,2)),g=c(rep(c(1,2),2)))
> xyplot(x~u,groups=g,
>  data=test,
>  par.settings=list(
>     superpose.symbol=list(pch=c(22, 23),cex=c(1.7,1.6),col="black")
>     ),
>  key=list(
>     text=list(c("t1","t2")),
>     space = "bottom",pch=c(23, 22),
>     points=F,
>     cex=1.0,
>     col="black"
>     ),
> )
> As you see the symbols which have been plotted into the plotting area appear
> to have some filling color while in the legend there is no filling color
> although the specification of the symbols is the same.
> If I use a normal plot command, the symbols are also not filled:
> plot(c(1,2,3),c(1,2,3),pch=c(22,23,24),cex=1.5)
> That problem must have occured during a recent lattice update since the color
> was not there when I was plotting a year ago with R2.5.x and some older
> lattice. It occurs on my linux as well as on my windows machine both with R
> 2.6.1 and latest lattice from CRAN.
> So here my questions: How do I get rid of the color? (or is it a bug?) If it
> is a feature, so how do I determine the color in both the symbols in the
> legend and in the plot itself? (Actually I was overlaying two plots e.g. one
> colored diamond and one empty diamond to achieve that effect but if there is
> a more efficient way to draw bordered symbols with customized color that
> would be preferable...)

It's a change in behaviour (in the sense that the default fill is no
longer transparent). Otherwise there doesn't seem to be any bug. The
whole point of using par.settings is so that you can use auto.key, and

   superpose.symbol=list(pch=c(22, 23),cex=c(1.7,1.6),col="black")
 auto.key = list(space = "bottom"))

gives a consistent legend. If you want the fill color to be
transparent, just specify fill="transparent" as Sundar suggested (but
then why are you using these plotting characters?). Something like col
= "black", fill = c("transparent", "black") should give you filled and
empty characters.


More information about the R-help mailing list