
Last chance! 50% off unlimited learning
Sale ends in
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.
shadowtext(x, y = NULL, labels, col = "white", bg = "black",
theta = seq(pi/32, 2 * pi, length.out = 64), r = 0.1,
cex = 1, ...)
This function is run for its side effects, returns NULL.
x-coordinates for the text
y-coordinates for the text
The text labels to plot
Color of the text
Color of the background shadow
Angles for plotting the background
Thickness of the shadow relative to plotting size
Character expansion passed through to text
and used in computing text size.
Additional arguments passed on to text
Greg Snow, 538280@gmail.com, with improvements by Thomas Danhorn
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.
plot(1:10, 1:10, bg='aliceblue')
rect(3,3,5,8, col='navy')
text(5,6, 'Test 1', col='lightsteelblue')
shadowtext(5,4, 'Test 2', col='lightsteelblue')
Run the code above in your browser using DataLab