add_labels: Add a labels look to a shape.

View source: R/add_look.R

add_labelsR Documentation

Add a labels look to a shape.

Description

Not applicable for shapes of type 'refline'.

Usage

add_labels(
  pj,
  text,
  size = 10,
  font = "sans",
  style = "plain",
  tc = "black",
  ta = 0.5,
  hj = 0.5,
  vj = 0.5,
  parse = FALSE,
  a = 0,
  fc = "white",
  fa = 0.5,
  lc = "black",
  la = 0.5,
  lt = "-",
  lw = 1,
  au = "r",
  dx = 0,
  dy = 0,
  shape = ".",
  name = "."
)

Arguments

pj

an object of class 'pj'.

text

character vector containing labels to add to x-y locations of shapes. Special values are '@xX' for printing the x values with X decimal point; '@yY' for printing the y values with Y decimal points, and '@xXyY' to print the x and y values with X and Y decimal points respectively.

X and Y can be any digit from 0 to 9. For example, if the x and y values of a point were pi and e, the following labels wquld be printed at the coordinate (pi, e): '@x0' would print '3', '@y8' would print '2.71828183', and '@x2y3' would print '(3.14, 2.718)'

size

positive numeric vector giving text size in points.

font

character vector giving label fonts. Valid values are 'mono', 'sans', 'serif', 'American Typewriter', 'Arial', 'Bradley Hand ITC', 'Calibri', 'Comic Sans MS', 'Courier', 'Courier New', 'Garamond', 'Geneva', 'Helvetica', 'Impact', 'Monaco', 'Palatino', 'Symbol', 'Tahoma', 'Times', 'Times New Roman', 'Trebuchet MS', and 'Verdana'.

'mono' uses the default monospaced font for the device/R configuration. 'sans' uses the default sans serif font for the device/R configuration. 'serif' uses the default serif font for the device/R configuration.

style

character vector giving text style. 'p' indicates plain, 'b' indicates bold, 'i' indicates italic, and 'bi' indicates bold italic.

tc

character vector giving valid text color specifications for labels.

ta

proportion vector (i.e., between 0 and 1 inclusive) indicating the alpha opacity of the text color (0 = fully transparent, 0.5 = translucent, 1 = fully opaque).

hj, vj

numeric proportion vectors (i.e., all values are between 0 and 1 inclusive) giving the horizontal justification and vertical justification, respectively. 0 indicates left or bottom justification, 1 indicates right or top justification, and 0.5 indicates middle or center justification.

parse

logical vector indicating whether to parse the labels (e.g., to print labels with Greek letters or mathematical expressions).

a

numeric vector giving angle of text rotation.

fc

NA or a character vector of fill colors for (optional) label background rectangles.

fa

NA or a proportion vector (i.e., all values are between 0 and 1, inclusive) indicating fill alpha opacity values for (optional) label background rectangles (0 is transparent, 1 is opaque, 0.5 is translucent).

lc

NA or a character vector of line colors for (optional) label background rectangles.

la

NA or a proportion vector (i.e., all values are between 0 and 1, inclusive) indicating line alpha opacity values for (optional) label background rectangles (0 is transparent, 1 is opaque, 0.5 is translucent).

lt

NA or a character vector indicating line type for (optional) label background rectangles, where '-' indicates a solid line, ':' indicates a dotted line, '=' indicates a dashed line, ':=' indicates a dot-dash line, 'LD' indicates a long-width dashed line, and '2D' indicates a double-width dashed line.

lw

NA or a positive numeric vector indicating proportional line width for (optional) background rectangles relative to the default (i.e., 1 gives the default line width, 01/2 gives half the default line width, and 2 gives double the default line width.)

au

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

dx

numeric vector giving horizontal offset from x for label positioning.

dy

numeric vector giving vertical offset from x for label positioning.

shape

character scalar indicating the type of shape to which the look will be applied.

Value

pj with the addition of the label look applied to the specified shape.

Valid combinations of argument properties

Labels can be validly described using patterns of argument properties as follows, where base indicates that the argument set (text, tc, ta, font, size, style, hj, vj, a, parse, au, dx, dy) have all been supplied, line indicates that the argument set (lc, la, lt) have all been supplied. and fill indicates that the argument set (fc, fa) have both been supplied.

base

The label text is printed without any enclosure

.

base + line

The label in text is printed in an outlined enclosure

.

base + fill

The label in text is printed in a filled enclosure

.

base + line + fill

The label in text is printed in an outlined and filled enclosure

.

Argument recycling

The arguments text, tc, ta, font, size, style, hj, vj, a, parse, fc, fa, lc, la, lt, lw, au, dx, and/or dy are recycled with the number of x-y pairs used to draw the shape to which the label look is applied

See Also

Other add_look: add_ci(), add_ends(), add_fills(), add_glyphs(), add_lines(), add_marks()


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