Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
It seems the grob settings are vectorized over x and y
library(grid)

g <- textGrob(
  label = c("1", "2", "3"),
  gp = gpar(
    fontsize = 1:3 * 50,
    cex = 1,
    fontfamily = "",
    fontface = "plain",
    col = ggplot2::alpha(c("black", "red"), 0.5)
  )
)

grid.newpage()
grid.draw(g)

g$x <- unit(c(0.5, 0.5), "npc")

grid.newpage()
grid.draw(g)

g$x <- unit(1:6 * 0.05 + 0.2, "npc")
g$y <- unit(1:6 * 0.05 + 0.2, "npc")

grid.newpage()
grid.draw(g)

Created on 2019-08-20 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.