shadowtext: Add text to a plot with a contrasting background.
Description
This is similar to the text function, but it also puts a background
shadow (outline) behind the text to make it stand out from the
background better.
Usage
shadowtext(x, y = NULL, labels, col = "white", bg = "black",
theta = seq(pi/4, 2 * pi, length.out = 8), r = 0.1, ...)
Arguments
x
x-coordinates for the text
y
y-coordinates for the text
labels
The text labels to plot
col
Color of the text
bg
Color of the background shadow
theta
Angles for plotting the background
r
Thickness of the shadow relative to plotting size
…
Additional arguments passed on to text
Value
This function is run for its side effects, returns NULL.
Details
When adding text to a plot it is possible that the color of the text
may make it difficult to see relative to its background. If the text
spans different backgrounds then it may not be possible to find a
single color to give proper contrast.
This function creates a contrasting shadow for the text by first
plotting several copies of the text at angles theta and
distance r in the background color, then plotting the text on
top.
This gives a shadowing or outlining effect to the text making it
easier to read on any background.