fill_pattern {fillpattern}R Documentation

Patterned Fills for Grobs

Description

Patterned Fills for Grobs

Usage

fill_pattern(
  patterns = "brick",
  fg = "black",
  bg = "transparent",
  angle = 0,
  width = 5,
  height = NA,
  lwd = 1,
  lty = "solid",
  fun = NULL
)

fillPatternGrob(
  pattern = "brick",
  fg = "black",
  bg = "transparent",
  angle = 0,
  width = 5,
  height = NA,
  lwd = 1,
  lty = "solid",
  fun = NULL
)

Arguments

patterns, pattern

The pattern specification. Options are "brick", "chevron", "fish", "grid", "herringbone", "hexagon", "octagon", "rain", "saw", "shingle", "rshingle", "stripe", and "wave", optionally abbreviated and/or suffixed with modifiers. See "Pattern Names" section below. Default: "brick"

fg

Foreground color, for the pattern's lines. Default: "black"

bg

Background color (or grob). Default: "transparent"

angle

How much the rotate the pattern, given in degrees clockwise. Default: 0

width

The width of the pattern tile. Assumed to be millimeters unless set otherwise with unit(). Default: 5

height

The height of the pattern tile, or NA to match width. Assumed to be millimeters unless set otherwise with unit(). Default: NA

lwd

Line width. A positive number. See graphics::par() for additional details. Default: 1

lty

Line type. One of "solid", "dashed", "dotted", "dotdash", "longdash", or "twodash". See graphics::par() for additional details. Default: "solid"

fun

A function for modifying graphical parameters immediately before rendering. Should accept two parameters: env, an environment that the function should modify, and row, the row of transformed data that ggbuild has constructed for this grob (including aes mappings). The return value is not used. Default: NULL

Details

fillPatternGrob() expects a single value for each parameter. fill_pattern() can accept a vector of values for each parameter which are subset or recycled as needed to obtain the same number as length(patterns).

Value

fill_pattern() returns a list of grid::pattern() objects; fillPatternGrob() returns a grid::gTree() object.

Pattern Names

Base name:

Angle modifier:

Width and height modifier:

Line width and style:

Combinations:

See Also

scale_fill_pattern() for ggplot2 integration.

Examples

    library(grid)
    library(fillpattern)
    
    grid.newpage()
    grid.rect(gp = gpar(fill = fill_pattern("brick", bg = "gray", angle = 90)))
    
    grid.newpage()
    gp <- Map(gpar, fill = fill_pattern(
      patterns = c("grid_3lwd", "stripe_longdash", "herringbone45", "hexagon_lg"),
      fg       = c("black",     "white",           "black",         "blue"),
      bg       = c("white",     "black",           "cyan",          "beige") ))
    grid.circle( gp = gp[[1]], x = 1/4, y = 3/4, r = 1/5)
    grid.polygon(gp = gp[[2]], x = c(9,12,15)/16, y = c(15,9,15)/16)
    grid.rect(   gp = gp[[3]], x = 1/4, y = 1/4, width = 2/5, height = 2/5)
    grid.rect(   gp = gp[[4]], x = 3/4, y = 1/4, width = 2/5, height = 2/5)

[Package fillpattern version 1.0.1 Index]