new_area: Add an area shape to a plot

View source: R/new_polycurve.R

new_areaR Documentation

Add an area shape to a plot

Description

An area shape is a polygon defined as the area between a curve (a set of x-y pairs) and a reference line. The default reference line is the x-axis.

Usage

new_area(
  pj,
  x,
  y,
  ref = "x",
  dir = "v",
  x1 = NA,
  y1 = NA,
  x2 = NA,
  y2 = NA,
  s = NA,
  i = NA,
  a = NA,
  au = "r",
  region = ".",
  look = NULL,
  mod = NULL,
  name = "."
)

Arguments

pj

an object of class 'pj'.

x

numeric vector defining the horizontal locations of points on a curve. The longer of x and y must have at least 2 elements.

y

numeric vector defining the vertical locations of points on a curve. The longer of x and y must have at least 2 elements.

ref

NA or a character scalar giving a pre-defined reference line. 'i' indicates the identity line 'x' indicates the x-axis, and 'y' indicates the y-axis.

dir

character scalar identifying the directional orientation of the reference line, where 'v' indicates a vertically-oriented area plot (the vertical area between the x-y curve and the reference line) and 'h' indicates a horizontally-oriented area plot.

x1

NA or a numeric scalar indicating either a vertical reference line at the value contained in x1 (if used alone) or the horizontal location of a primary point used to define a reference line (if used with y1).

y1

NA or a numeric scalar indicating either a horizontal reference line at the value contained iny1 (if used alone) or the vertical location of a primary point used to define a reference line (if used with x1).

x2

NA or a numeric scalar indicating the horizontal location of the secondary points to define a reference line (in conjunction with x1, y1, and y2).

y2

NA or a numeric scalar indicating the vertical location of the secondary points to define a reference line (in conjunction with x1, y1, and x2).

s

NA or a numeric scalar indicating the slope of the reference line.

i

NA or a numeric scalar indicating the intercept of the reference line.

a

NA or a numeric scalar indicating the angle of the reference line.

au

NA or a character vector indicating the angle units to be used where 'd' indicates degrees, 'g' indicates gradians, 'p' indicates proportion of a full revolution, 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.

Value

pj with the addition of the specified area shape.

Defining reference lines

Valid combinations of non-NA locating arguments are given below.

ref

Pre-defined reference line

x1

Vertical line at x1.

y1

Horizontal line at y1.

x1 + y1 + x2 + y2

Point-point definition (line through (x1, y1) and (x2, y2)).

x1 + y1 + a

Point-angle definition (line through (x1, y1) at angle a).

x1 + y1 + i

Point-intercept definition (line through intercept and (x1, y1)).

x1 + y1 + s

Point-slope definition (line through (x1, y1) with slope s).

a + i

Angle-intercept definition (line through intercept at angle a).

s + i

Slope-intercept definition (line through intercept with slope s.

Argument recycling

The argument set {x, y} is 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_ribbon()


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