new_segments: Add a segments shape to a plot

View source: R/new_simples.R

new_segmentsR Documentation

Add a segments shape to a plot

Description

A segments shape is a collection of lines between two points (each) that use the same subset of locating arguments (x, y, x2, y2, m, s, a, and au).

Usage

new_segments(
  pj,
  x1,
  y1,
  x2 = NA,
  y2 = NA,
  d = NA,
  s = NA,
  a = NA,
  au = "r",
  region = ".",
  look = NULL,
  mod = NULL,
  name = "."
)

Arguments

pj

an object of class 'pj'.

x1

numeric vector giving the horizontal start point of each segment.

y1

numeric vector giving the vertical start point of each segment.

x2

NA or a numeric vector giving the horizontal end point of each segment.

y2

NA or a numeric vectors giving the vertical end point of each segment.

s

NA or a numeric vector giving the slope of each segment.

a

NA or a numeric vector giving the angle of each segment.

au

NA or a character vector giving the angle units where 'd' indicates degrees, 'g' indicates gradians, 'p' indicates proportion of a full rotation, and 'r' indicates radians.

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.

m

NA or a numeric vector giving the magnitude (length) of each segment.

Value

pj with the addition of the specified line segment shape(s).

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_glyphs, add_labels, add_lines, and add_marks functions. Sub-lists of the look argument must be named 'end', '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.

Argument recycling

The argument set {x1, y1, x2, y2, m, s, a, au} is recycled.

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_simples: new_points(), new_reflines()


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