shadowtext: Add border to plotted text

View source: R/shadowtext.R

shadowtextR Documentation

Add border to plotted text

Description

Add border to plotted text

Usage

shadowtext(
  x,
  y = NULL,
  labels,
  col = "white",
  bg = "black",
  theta = seq(0, 2 * pi, length.out = 50),
  r = 0.1,
  ...
)

Arguments

x, y

numeric vectors of coordinates where the text labels should be written. If the length of x and y differs, the shorter one is recycled.

labels

a character vector or expression specifying the text to be written. An attempt is made to coerce other language objects (names and calls) to expressions, and vectors and other classed objects to character vectors by as.character. If labels is longer than x and y, the coordinates are recycled to the length of labels.

col

the color of the text.

bg

the color of the text border

theta

a sequence of angles be which to cycle around the text. (Default: theta = seq(0, 2*pi, length.out = 50))

r

the width of the border (fraction of character width).

...

other pars passed to text.

Value

lower level plotting command to add text to existing device.

References

https://stackoverflow.com/a/25632536/1199289

Examples


plot(c(0,1), c(0,1), type="n", lwd=20, axes=FALSE, xlab="", ylab="")

rect(xleft = 0.5, xright = 1, ybottom = 0, ytop = 1, col=1)
text(1/6, 1/6, "Test 1")
shadowtext(2/6, 2/6, "Test 2", col='red', bg="blue")
shadowtext(3/6, 3/6, "Test 3", cex=2)

# `r` controls the width of the border
shadowtext(5/6, 5/6, "Test 4", col="black", bg="white", cex=4, r=0.2)


marchtaylor/sinkr documentation built on July 4, 2022, 5:48 p.m.