I have a lattice figure that contains a multi-line expression()
statement. I want to fine–tune the vertical space between the lines of this statement. Is there a way to do this?
Here is code that demonstrates the problem:
library(devtools)
library(grid)
library(lattice)
source_gist(2732693) # source grid.expr()
# PANEL FUNCTIONS
myPanel1 <- function () {
grid.text(
label = expression(atop("This is", paste("italicized ", italic(F))),
gp = gpar(lineheight = 5)))
}
myPanel2 <- function () {
grid.expr(
as.expression(
list("This is", bquote(paste("italicized ", italic(F))))),
gp = gpar(lineheight = 5))
}
# DRAW THE FIGURES
xyplot(1 ~ 1, panel = myPanel1)
xyplot(1 ~ 1, panel = myPanel2)
This code offers two ways to create a multi-line expression()
statement in a lattice plot. But the gp
argument is ignored in both cases, and I don't see a way to adjust the vertical spacing of lines within the expression. Is there a way to do this, short of "manually" positioning the lines with a separate grid.text
or grid.expr
command for each line?