new_ribbon: Add a ribbon shape to a plot

View source: R/new_polycurve.R

new_ribbonR Documentation

Add a ribbon shape to a plot

Description

A ribbon shape is a polygon defined as the area between two curves (two sets of x-y pairs).

Usage

new_ribbon(
  pj,
  order = "x",
  dir = "v",
  x1 = NA,
  y1 = NA,
  x2 = NA,
  y2 = NA,
  region = ".",
  look = NULL,
  mod = NULL,
  name = "."
)

Arguments

pj

an object of class 'pj'.

order

character scalar 'x', 'y', or 'i' indicating ordering x-y pairs on the value of x and x2, ordering x-y pairs on the value of y and y2, and identity, or leaving the order of x-y pairs unchanged.

dir

character scalar identifying the directional orientation of the ribbon. 'v' indicates a vertically-oriented ribbon, or the vertical area between the two curves. 'h' indicates a horizontally-oriented ribbon.

x1

numeric vector giving the horizontal location of points on the first curve. The longer of x or y must have at least 2 values.

y1

numeric vector giving the vertical location of points on the first curve. The longer of x or y must have at least 2 values.

x2

numeric vector giving the horizontal location of points on the second curve. The longer of x2 or y2 must have at least 3 values.

y2

numeric vector giving the vertical location of points on the second curve. The longer of x2 or y2 must have at least 3 values.

region

either character scalar "." to indicate the most recently used region, a positive integer to indicate the ID number of a region (0 indicates the background region), or a character scalar to indicate the name of a region ('bg' indicates the background region).

look

an optional list containing up to four lists specifying looks to apply to the shape. See the using look to make shapes appear section.

mod

an optional list containing up to four lists specifying modifications to apply to the shape. See the using mod to transform shapes section.

name

character scalar indicating a name for the shape. The special value "." indicates that the pj package create a default name for the shape.

Value

pj with the addition of the defined ribbon.

Argument recycling

The argument set {x1, y1} is recycled. The argument set {x2, y2} is separately recycled.

Using look to make shapes appear

By itself, this function simply defines the location of x-y pairs in the assigned region for the specified shape. Various looks can be added to the shape using the look parameter or via the add_ends, add_fills, add_glyphs, add_labels, add_lines, and add_marks functions. Sub-lists of the look argument must be named 'end', 'fill', 'glyph', 'label', 'line', and/or 'mark' to indicate that line end marks, fill colors, glyphs (single characters), labels, lines, and/or point marks be added to the shape.

Using mod to transform shapes

Shapes can be transformed in four ways: dilation, reflection, rotation, and translation/. using the mod argument or the mod_dilate, mod_reflect, mod_rotate, and mod_translate. Sub-lists of the mod argument must be named 'dilate', 'reflect', 'rotate', and/or 'translate' to indicate that a dilation, reflection, rotation, and or translation be applied to the shape.

See Also

Other new_polycurve: new_area()


j-martineau/pj documentation built on March 19, 2022, 5:32 a.m.