Examples for 'grid::gpar'


Handling Grid Graphical Parameters

Aliases: gpar get.gpar

Keywords: dplot

### ** Examples

gp <- get.gpar()
utils::str(gp)
List of 14
 $ fill      : chr "white"
 $ col       : chr "black"
 $ lty       : chr "solid"
 $ lwd       : num 1
 $ cex       : num 1
 $ fontsize  : num 12
 $ lineheight: num 1.2
 $ font      : int 1
 $ fontfamily: chr ""
 $ alpha     : num 1
 $ lineend   : chr "round"
 $ linejoin  : chr "round"
 $ linemitre : num 10
 $ lex       : num 1
 - attr(*, "class")= chr "gpar"
## These *do* nothing but produce a "gpar" object:
gpar(col = "red")
$col
[1] "red"
gpar(col = "blue", lty = "solid", lwd = 3, fontsize = 16)
$col
[1] "blue"

$lty
[1] "solid"

$lwd
[1] 3

$fontsize
[1] 16
get.gpar(c("col", "lty"))
$col
[1] "black"

$lty
[1] "solid"
grid.newpage()
vp <- viewport(width = .8, height = .8, gp = gpar(col="blue"))
grid.draw(gTree(children=gList(rectGrob(gp = gpar(col="red")),
                     textGrob(paste("The rect is its own colour (red)",
                                    "but this text is the colour",
                                    "set by the gTree (green)",
                                    sep = "\n"))),
      gp = gpar(col="green"), vp = vp))
grid.text("This text is the colour set by the viewport (blue)",
          y = 1, just = c("center", "bottom"),
          gp = gpar(fontsize=20), vp = vp)
plot of chunk example-grid-gpar-1
grid.newpage()
## example with multiple values for a parameter
pushViewport(viewport())
grid.points(1:10/11, 1:10/11, gp = gpar(col=1:10))
popViewport()
plot of chunk example-grid-gpar-1

[Package grid version 4.2.3 Index]