Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(lattice)
- library(grid)
- leftText <- "words\nwords2\nwords3"
- rightText <- "words\nwords2"
- bottomPadding <- (max(sapply(gregexpr("\n", c(leftText, rightText)), length)) + 1L) * 2 + 2
- xyplot(
- y ~ x, data.frame(x = rnorm(100), y = rnorm(100)),
- par.settings = list(layout.heights = list(bottom.padding = bottomPadding)),
- panel = function(x, y, ...) {
- panel.xyplot(x, y, ...)
- xscale <- current.viewport()$xscale
- yscale <- current.viewport()$yscale
- pushViewport(viewport(width = 2, height = 2, clip = TRUE))
- pushViewport(viewport(width = 0.5, height = 0.5, xscale = xscale, yscale = yscale))
- grid.text("v", unit(c(-0.5, 0, 0.5), "native"), unit(1, "npc") + unit(1, "mm"), c("center", "bottom"))
- grid.text(c("L", "U"), unit(0, "npc") - unit(2, "mm"), unit(c(-2, 2), "native"), c("center", "bottom"),
- gp = gpar(col = "red"))
- popViewport(2)
- },
- page = function(page){
- grid.text(leftText, 0.02, 0.02, c("left", "bottom"))
- grid.text(rightText, 0.98, 0.02, c("right", "bottom"))
- }, scales = list(tck = c(1, 0))
- )
Add Comment
Please, Sign In to add comment