new_rounds: Add a proportional-vertex rounds shape to a plot

View source: R/new_rounds.R

new_roundsR Documentation

Add a proportional-vertex rounds shape to a plot

Description

A proportional-vertex rounds shape is a collection of rounded shapes defined by proportional location of bottom, top, left, and right vertex locations that use the same subset of locating arguments from among x, y, n, px, py, rx, ry, re, te, and pv. Pvrounds are located in plotting regions using bounding rectangles, a concept used in defining function parameters. See the defining bounding rectangles section for details. They are defined by specifying, proportionally, using pv, where from left to right edge the bottom-most and top-most vertices lie, and from bottom to top edge where left-most and right-most vertices lie.

Usage

new_rounds(
  pj,
  pv,
  x,
  y,
  w = NA,
  h = NA,
  re = NA,
  te = NA,
  px = 0.5,
  py = 0.5,
  n = 100,
  region = ".",
  look = NULL,
  mod = NULL,
  name = "."
)

Arguments

pj

an object of class 'pj'.

pv

proportion vector of length 4 giving, in order, the vertical location of the left-edge vertex as a proportion of the distance from bottom edge to top edge, the bottom-edge vertex as a proportion of the distance from left edge to right edge, the right-edge vertex as a proportion of the distance from bottom to top edge, and the top-edge vertex as a proportion of the distance from left edge to right edge.

x

numeric vector giving horizontal location. When x is used in conjunction with px and w these vectors define a fixed horizontal point for each shape. When x is used in conjunction with re, x defines the left edge of the bounding rectangle of each shape.

y

numeric vector giving vertical location. When y is used in conjunction with py and h these vectors define a fixed vertical point for each shape. When y is used in conjunction with te,y defines the bottom edge of the bounding rectangle of each shape.

w

NA or a numeric vector defining the width of each bounding rectangle.

h

NA or a numeric vector defining the height of each bounding rectangle.

re

NA or a numeric vector defining the right edge of each bounding rectangle.

te

NA or a numeric vector defining the top edge of each bounding rectangle.

px

NA or a proportion vector defining the location of x as the proportion of the distance from left to right edge of bounding rectangles. Values are generally between 0 and 1, inclusive, however, when they are outside those values, fixed points x will lie outside bounding rectangles.

py

NA or a proportion vector defining the location of y as the proportion of the distance from bottom to top edge of bounding rectangles. Values are generally between 0 and 1, inclusive, however, when they are outside those values, fixed points y will lie outside bounding rectangles.

n

positive whole-number vector giving the number of vertices to calculate for plotting each shape. All values must be between 3 and 1000, inclusive.

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 proportional-vertex rounds.

Defining bounding rectangles

Bounding rectangles can be located in a number of ways. The following shows valid combination of non-NA locating arguments:

(x + px) + w + (y + py) + h

(horizontal anchor) + width + (vertical anchor) + height

(x + px) + w + y + te

(horizontal anchor) + height + bottom edge + top edge

x + re + (y + py) + h

left edge + right edge + (vertical anchor) + height

x + re + y + te

left edge + right edge + bottom edge + top edge

Argument recycling

The argument set {x, y, w, h, re, te, px, py, n} is recycled.

Bounding rectangles, px, and py

When px is not NA, it represents where the value x is located as a proportion of the distance between the left and right edge of each bounding rectangle. Likewise, when py is not NA, it represents where the value y is located as a proportion of the distance between the bottom and top edge of each bounding rectangle. For example:

  • when px = 0.5 and py = 0.5, the center of the bounding rectangle is located at (x, y).

  • when px = 0 and py = 0, the bottom left corner of the bounding rectangle is located at (x, y).

  • when px = 1 and py = 1, the top right corner of the bounding rectangle is located at (x, y).

  • when px = 1/3 and py = 2/3, the point 1/3 of the way from left to right edge and 2/3 of the way from bottom to top edge of the bounding rectangle is located at (x, y).

px and py can be less than 0 or greater than 1, resulting in the fixed point (x, y) being outside the bounding rectangle.

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_rounds: new_circles(), new_ellipses()


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