Re: [R] dotplot (lattice) with panel.segments and groups
"Gabor Grothendieck" <[EMAIL PROTECTED]> wrote: On 7/7/06, Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > On 7/7/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: >>> Could you explain what panel.groups= does and what the difference >>> is between panel.groups= and panel= ? In ?xyplot it just says: >>> panel.groups: useful mostly for 'xyplot' and 'densityplot'. Applies >>> when 'panel' is 'panel.superpose' (which happens by default >>> in these cases if 'groups' is non-null) >>> which indicates when it might apply but not what it does. >> That's wrong (it used to be right - a good example of why \synopsis is >> bad). Since lattice 0.13-x, panel.superpose is never the default panel >> function. An updated version with improved documentation should be out >> soon. >> 'panel.groups' is simply an argument to panel.superpose, and is >> described in ?panel.superpose. Thus, it only makes sense as an >> argument to xyplot/dotplot/whatever when the panel function is >> panel.superpose, and not otherwise. The entry for the graphical >> parameters in ?panel.superpose isn't as useful as it could be, I have >> just updated it to read: >> col, col.line, col.symbol, pch, cex, fill, font, fontface, >> fontfamily, lty, lwd, alpha: graphical >> parameters, replicated to be as long as the number of >> groups. These are eventually passed down to 'panel.groups', >> but as scalars rather than vectors. When 'panel.groups' is >> called for the i-th level of 'groups', the corresponding >> element of each graphical parameter is passed to it. >> Hope that makes things a bit clearer. Thanks Gabor and Deepayan for your responses. Cheers, -- Seb __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dotplot (lattice) with panel.segments and groups
On 7/7/06, Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > On 7/7/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > > Could you explain what panel.groups= does and what the difference > > is between panel.groups= and panel= ? In ?xyplot it just says: > > > > panel.groups: useful mostly for 'xyplot' and 'densityplot'. Applies > > when 'panel' is 'panel.superpose' (which happens by default > > in these cases if 'groups' is non-null) > > > > which indicates when it might apply but not what it does. > > That's wrong (it used to be right - a good example of why \synopsis is > bad). Since lattice 0.13-x, panel.superpose is never the default panel > function. An updated version with improved documentation should be out > soon. > > 'panel.groups' is simply an argument to panel.superpose, and is > described in ?panel.superpose. Thus, it only makes sense as an > argument to xyplot/dotplot/whatever when the panel function is > panel.superpose, and not otherwise. The entry for the graphical > parameters in ?panel.superpose isn't as useful as it could be, I have > just updated it to read: > > col, col.line, col.symbol, pch, cex, fill, font, fontface, > fontfamily, lty, lwd, alpha: graphical > parameters, replicated to be as long as the number of > groups. These are eventually passed down to 'panel.groups', > but as scalars rather than vectors. When 'panel.groups' is > called for the i-th level of 'groups', the corresponding > element of each graphical parameter is passed to it. > > Hope that makes things a bit clearer. > > Deepayan > Thanks. That does help. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dotplot (lattice) with panel.segments and groups
On 7/7/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Could you explain what panel.groups= does and what the difference > is between panel.groups= and panel= ? In ?xyplot it just says: > > panel.groups: useful mostly for 'xyplot' and 'densityplot'. Applies > when 'panel' is 'panel.superpose' (which happens by default > in these cases if 'groups' is non-null) > > which indicates when it might apply but not what it does. That's wrong (it used to be right - a good example of why \synopsis is bad). Since lattice 0.13-x, panel.superpose is never the default panel function. An updated version with improved documentation should be out soon. 'panel.groups' is simply an argument to panel.superpose, and is described in ?panel.superpose. Thus, it only makes sense as an argument to xyplot/dotplot/whatever when the panel function is panel.superpose, and not otherwise. The entry for the graphical parameters in ?panel.superpose isn't as useful as it could be, I have just updated it to read: col, col.line, col.symbol, pch, cex, fill, font, fontface, fontfamily, lty, lwd, alpha: graphical parameters, replicated to be as long as the number of groups. These are eventually passed down to 'panel.groups', but as scalars rather than vectors. When 'panel.groups' is called for the i-th level of 'groups', the corresponding element of each graphical parameter is passed to it. Hope that makes things a bit clearer. Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dotplot (lattice) with panel.segments and groups
Could you explain what panel.groups= does and what the difference is between panel.groups= and panel= ? In ?xyplot it just says: panel.groups: useful mostly for 'xyplot' and 'densityplot'. Applies when 'panel' is 'panel.superpose' (which happens by default in these cases if 'groups' is non-null) which indicates when it might apply but not what it does. Also can we assume from the above that the panel=panel.superpose in your response could have been omitted? Thanks. On 7/7/06, Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > On 7/7/06, Sebastian Luque <[EMAIL PROTECTED]> wrote: > > Hi, > > > > The following produces almost exactly what I needed. The problems are > > that the 'panel.dotplot' call (commented) generates the error 'Error in > > NextMethod("[") : argument "subscripts" is missing, with no default'. > > It's just as it says: panel.dotplot wants a 'subscripts' argument when > 'groups' is not null, and you have forgotten to give it one. > > > The > > other problem is that the colors alternate between the levels of the 'site' > > variable, rather than 'year'. > > It's doing what it's being told to do. You probably want something like > > dotplot(site ~ yield | variety, data=barley, >groups=year, yield2=barley$yield2, >col=c("gray", "black"), >panel = panel.superpose, >panel.groups = function(x, y, subscripts, yield2, col, ...) { >panel.xyplot(x, y, col = col, ...) >panel.segments(x, y, yield2[subscripts], y, col = col) >}) > > Note that you don't want to use panel.dotplot here as it would draw a > reference line both times. If you do want a reference line, add that > in the panel function. > > The explicit use of 'col' should not have been necessary, i.e., the > following should have worked: > > dotplot(site ~ yield | variety, data=barley, >groups=year, yield2=barley$yield2, >col=c("gray", "black"), >panel = panel.superpose, >panel.groups = function(x, y, subscripts, yield2, ...) { >panel.xyplot(x, y, col = ...) >panel.segments(x, y, yield2[subscripts], y, ...) >}) > > I believe this doesn't work because of a grid bug. I'll take that up > in a separate thread. > > -Deepayan > > > > > > > barley$yield2 <- with(barley, yield + 5) > > > > dotplot(site ~ yield | variety, data=barley, groups=year, > > yield2=barley$yield2, col=c("gray", "black"), > > panel=function(x, y, subscripts, yield2, ...) { > > ## panel.dotplot(x, y, ...) > > panel.segments(x, as.numeric(y), > >yield2[subscripts], as.numeric(y), ...) > > }) > > > > R> sessionInfo() > > Version 2.3.1 (2006-06-01) > > i486-pc-linux-gnu > > > > attached base packages: > > [1] "methods" "stats" "graphics" "grDevices" "utils" "datasets" > > [7] "base" > > > > other attached packages: > >chron gmodels lattice > > "2.3-3" "2.12.0" "0.13-8" > > > > > > Can somebody please suggest how to properly make that 'panel.dotplot' call > > and set the 'col' argument? Thanks in advance. > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dotplot (lattice) with panel.segments and groups
On 7/7/06, Sebastian Luque <[EMAIL PROTECTED]> wrote: > Hi, > > The following produces almost exactly what I needed. The problems are > that the 'panel.dotplot' call (commented) generates the error 'Error in > NextMethod("[") : argument "subscripts" is missing, with no default'. It's just as it says: panel.dotplot wants a 'subscripts' argument when 'groups' is not null, and you have forgotten to give it one. > The > other problem is that the colors alternate between the levels of the 'site' > variable, rather than 'year'. It's doing what it's being told to do. You probably want something like dotplot(site ~ yield | variety, data=barley, groups=year, yield2=barley$yield2, col=c("gray", "black"), panel = panel.superpose, panel.groups = function(x, y, subscripts, yield2, col, ...) { panel.xyplot(x, y, col = col, ...) panel.segments(x, y, yield2[subscripts], y, col = col) }) Note that you don't want to use panel.dotplot here as it would draw a reference line both times. If you do want a reference line, add that in the panel function. The explicit use of 'col' should not have been necessary, i.e., the following should have worked: dotplot(site ~ yield | variety, data=barley, groups=year, yield2=barley$yield2, col=c("gray", "black"), panel = panel.superpose, panel.groups = function(x, y, subscripts, yield2, ...) { panel.xyplot(x, y, col = ...) panel.segments(x, y, yield2[subscripts], y, ...) }) I believe this doesn't work because of a grid bug. I'll take that up in a separate thread. -Deepayan > > > barley$yield2 <- with(barley, yield + 5) > > dotplot(site ~ yield | variety, data=barley, groups=year, > yield2=barley$yield2, col=c("gray", "black"), > panel=function(x, y, subscripts, yield2, ...) { > ## panel.dotplot(x, y, ...) > panel.segments(x, as.numeric(y), >yield2[subscripts], as.numeric(y), ...) > }) > > R> sessionInfo() > Version 2.3.1 (2006-06-01) > i486-pc-linux-gnu > > attached base packages: > [1] "methods" "stats" "graphics" "grDevices" "utils" "datasets" > [7] "base" > > other attached packages: >chron gmodels lattice > "2.3-3" "2.12.0" "0.13-8" > > > Can somebody please suggest how to properly make that 'panel.dotplot' call > and set the 'col' argument? Thanks in advance. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dotplot (lattice) with panel.segments and groups
It seems to work if you handle the col= argument explicitly. Suggest you double check this since I have not carefully done so: barley$yield2 <- with(barley, yield + 5) dotplot(site ~ yield | variety, data=barley, groups=year, yield2=barley$yield2, col=c("gray", "black"), panel=function(x, y, subscripts, groups, yield2, col, ...) { panel.dotplot(x, y, ...) panel.segments(x, as.numeric(y), yield2[subscripts], as.numeric(y), col = col[groups[subscripts]], ...) }) On 7/7/06, Sebastian Luque <[EMAIL PROTECTED]> wrote: > Hi, > > The following produces almost exactly what I needed. The problems are > that the 'panel.dotplot' call (commented) generates the error 'Error in > NextMethod("[") : argument "subscripts" is missing, with no default'. The > other problem is that the colors alternate between the levels of the 'site' > variable, rather than 'year'. > > > barley$yield2 <- with(barley, yield + 5) > > dotplot(site ~ yield | variety, data=barley, groups=year, >yield2=barley$yield2, col=c("gray", "black"), >panel=function(x, y, subscripts, yield2, ...) { >## panel.dotplot(x, y, ...) >panel.segments(x, as.numeric(y), > yield2[subscripts], as.numeric(y), ...) >}) > > R> sessionInfo() > Version 2.3.1 (2006-06-01) > i486-pc-linux-gnu > > attached base packages: > [1] "methods" "stats" "graphics" "grDevices" "utils" "datasets" > [7] "base" > > other attached packages: > chron gmodels lattice > "2.3-3" "2.12.0" "0.13-8" > > > Can somebody please suggest how to properly make that 'panel.dotplot' call > and set the 'col' argument? Thanks in advance. > > > Cheers, > > -- > Seb > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html