deepayan / tessella

A framework for R graphics
GNU General Public License v3.0
0 stars 0 forks source link

draw.key infelicity #1

Open tyner opened 2 years ago

tyner commented 2 years ago

In lattice, one may do

key <- list(rep = FALSE, 
            just = "left", 
            draw = FALSE, 
            lines = list(col = c(foo = "red", bar = "blue"),
                         lty = c(1, 1), 
                         lwd = c(2, 2)
                         ),
            text = list(lab = c("foo", "bar"))
            )

g <- draw.key(key, draw = FALSE)

however in lattice0, it gives warnings and an error:

Warning in FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL Warning in FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL Warning in FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL Error in tstrheight(label, rot = rot, cex = gp$cex, font = gp$font, family = gp$family) : could not find function "tstrheight"

deepayan commented 2 years ago

Thanks, warnings fixed now by porting from lattice, in the sense that

xyplot(1 ~ 1, key = key)

should now work without warnings. A standalone g <- draw.key(key, draw = FALSE) will not work unless a backend is attached, e.g.,

attach(tessella::graphics_primitives())
g <- draw.key(key, draw = FALSE)
detach()