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...) Stefan
Stefan Grosse said the following on 1/11/2008 10:04 AM:> 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...) > > Stefan >Hi, Stefan You need to use "fill = 'transparent'" in your par.settings call. If you're not using a fill color, you probably should use pch = c(0, 5) instead. This is explained under pch on the ?points help page. Here's a modified version of your example: library(lattice) test <- data.frame(x = c(2, 3, 1, 5), u = rep(1:2, each = 2), g = paste("t", rep(1:2, 2), sep = "")) xyplot(x ~ u, data = test, groups = g, par.settings = list( superpose.symbol = list( pch = c(22, 23), cex = c(1.7, 1.6), fill = c("red", "blue"), col = "black")), auto.key = list(space = "bottom")) HTH, --sundar
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Stefan Grosse Sent: Friday, January 11, 2008 10:04 AM To: R help (E-mail) Subject: [R] lattice color problem with symbols: bug? 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. ......... Not for me. Both sets of symbols are identical and unfilled.> sessionInfo()R version 2.6.1 Patched (2007-12-03 r43574) i386-pc-mingw32 Bert Gunter Genentech Nonclinical Statistics
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 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") ), 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. -Deepayan
When I tryyyour code I am getting unfilled symbols, no colour. --- 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...) > > Stefan > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >