grid.pattern_polygon_tiling() draws a specified polygon tiling pattern onto the graphic device. names_polygon_tiling lists all supported types.

grid.pattern_polygon_tiling(
  x = c(0, 0, 1, 1),
  y = c(1, 0, 0, 1),
  id = 1L,
  ...,
  colour = gp$col %||% "grey20",
  fill = gp$fill %||% "grey80",
  angle = 30,
  spacing = 0.05,
  xoffset = 0,
  yoffset = 0,
  type = "square",
  alpha = gp$alpha %||% NA_real_,
  linetype = gp$lty %||% 1,
  size = gp$lwd %||% 1,
  default.units = "npc",
  name = NULL,
  gp = gpar(),
  draw = TRUE,
  vp = NULL
)

names_polygon_tiling

Arguments

x

A numeric vector or unit object specifying x-locations of the pattern boundary.

y

A numeric vector or unit object specifying y-locations of the pattern boundary.

id

A numeric vector used to separate locations in x, y into multiple boundaries. All locations within the same id belong to the same boundary.

...

Currently ignored

colour

Stroke colour

fill

Fill colour

angle

Rotation angle in degrees

spacing

Spacing between repetitions of pattern ('snpc' units between 0 and 1).

xoffset

Shift pattern along x axis ('snpc' units between 0 and 1).

yoffset

Shift pattern along y axis ('snpc' units between 0 and 1).

type

Name of polygon tiling to draw. See Details.

alpha

Alpha (between 0 and 1) or NA (default, preserves colors' alpha value). Not supported for all polygon tiling type.

linetype

Stroke linetype

size

Stroke linewidth

default.units

A string indicating the default units to use if x or y are only given as numeric vectors.

name

A character identifier.

gp

An object of class "gpar", typically the output from a call to the function gpar. This is basically a list of graphical parameter settings.

draw

A logical value indicating whether graphics output should be produced.

vp

A Grid viewport object (or NULL).

Format

An object of class character of length 12.

Value

A grid grob object invisibly. If draw is TRUE then also draws to the graphic device as a side effect.

Details

grid.pattern_polygon_tiling() supports 1, 2, or 3 fill colors with the first colors (weakly) covering a larger area. Size of the pattern is controlled by spacing. We support the following polygon tiling types:

herringbone

Creates a herringbone tiling made of rectangles.

hexagonal

Creates a hexagonal tiling made of hexagons.

pythagorean

Creates a Pythagorean tiling made of squares of two different sizes.

rhombitrihexagonal

Creates a rhombitrihexagonal tiling made out of dodecagons, hexagons, and squares.

snub_square

Creates a snub square tiling made of squares and triangles.

snub_trihexagonal

Creates a snub trihexagonal tiling made of hexagons and triangles.

square

Creates a square tiling made of squares.

triangular

Creates a triangular tiling made of equilateral triangles.

trihexagonal

Creates a trihexagonal tiling made of hexagons and triangles.

truncated_square

Creates a truncated square tiling made of octagons and squares.

truncated_hexagonal

Creates a truncated hexagonal tiling made of dodecagons and triangles.

truncated_trihexagonal

Creates a truncated trihexagonal tiling made of hexagons, squares, and triangles.

See also

The tiling vignette vignette("tiling", package = "gridpattern") for more information about these tilings as well as more examples of polygon tiling using the grid.pattern_regular_polygon() function.

Examples

print(names_polygon_tiling)
#> [1] "herringbone" "hexagonal" "pythagorean" #> [4] "rhombitrihexagonal" "snub_square" "snub_trihexagonal" #> [7] "square" "triangular" "trihexagonal" #> [10] "truncated_square" "truncated_hexagonal" "truncated_trihexagonal"
if (require("grid")) { x_hex <- 0.5 + 0.5 * cos(seq(2 * pi / 4, by = 2 * pi / 6, length.out = 6)) y_hex <- 0.5 + 0.5 * sin(seq(2 * pi / 4, by = 2 * pi / 6, length.out = 6)) gp1 <- gpar(fill = "yellow", col = "black") gp2 <- gpar(fill = c("yellow", "red"), col = "black") gp3 <- gpar(fill = c("yellow", "red", "blue"), col = "black") grid.pattern_polygon_tiling(x_hex, y_hex, type = "herringbone", gp = gp1) grid.newpage() grid.pattern_polygon_tiling(x_hex, y_hex, type = "hexagonal", gp = gp3) grid.newpage() grid.pattern_polygon_tiling(x_hex, y_hex, type = "pythagorean", gp = gp2) grid.newpage() grid.pattern_polygon_tiling(x_hex, y_hex, type = "truncated_square", gp = gp3) }