[R] lines through points in lattice legend

Kenneth Knoblauch ken@knob|@uch @end|ng |rom |n@erm@|r
Sat Jan 28 10:18:42 CET 2023


Hi,

I'm struggling to find if there is a simple way to make the lines and points overlap in a legend for a lattice plot using auto.key.  Here is a toy example of what doesn't work (for me) as the lines and points are adjacent rather than overlapping:

library(lattice)
d <- data.frame(x = 1:2, y = 1:4, f = factor(letters[1:2]))

xyplot(y ~ x, d, groups = f, type = "b", 
	pch = 21:22, fill = c("white", "black"), col = "black",
	par.settings = list(superpose.symbol = 
	list(pch = 21:22, fill = c("white", "black"), col = "black"),
	superpose.line = list(col = "black")),
	auto.key = list(space = "right", points = TRUE, lines = TRUE))

I've seen a few examples on stack.overflow but I haven't been able to make them work, or they seem more complicated then I would think it should be (but I don't exclude that I'm fooling myself there).

R version 4.2.2 Patched (2023-01-04 r83564)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lattice_0.20-45

loaded via a namespace (and not attached):
[1] compiler_4.2.2 grid_4.2.2    
     
 Thanks for any enlightenment, in advance.

Ken 
 
  ___
  Kenneth Knoblauch
 Inserm U1208
 Stem-cell and Brain Research Institute
 18 avenue du Doyen Lépine
 69500 Bron
 France
 tel: +33 (0)4 72 91 34 77
 fax: +33 (0)4 72 91 34 61
 portable: +33 (0)6 84 10 64 10
 https://sbri.fr/public-profile/63/single-member/
    


More information about the R-help mailing list