shadowText | R Documentation |
Draw text with shadow border
shadowText(
x,
y = NULL,
labels = NULL,
col = "white",
bg = setTextContrastColor(col),
r = getOption("jam.shadow.r", 0.15),
offset = c(0.15, -0.15),
n = getOption("jam.shadow.n", 8),
outline = getOption("jam.outline", TRUE),
alphaOutline = getOption("jam.alphaOutline", 0.4),
shadow = getOption("jam.shadow", FALSE),
shadowColor = getOption("jam.shadowColor", "black"),
alphaShadow = getOption("jam.alphaShadow", 0.2),
shadowOrder = c("each", "all"),
cex = par("cex"),
font = par("font"),
doTest = FALSE,
...
)
x , y |
numeric coordinates, either as vectors x and y, or x as a
two-color matrix recognized by |
labels |
vector of labels to display at the corresponding xy coordinates. |
col , bg , shadowColor |
the label color, and background (outline) color,
and shadow color (if |
r |
the outline radius, expressed as a fraction of the width of the
character "A" as returned by |
offset |
the outline offset position in xy coordinates, expressed
as a fraction of the width of the character "A" as returned by
|
n |
the number of steps around the label used to create the outline. A higher number may be useful for very large font sizes, otherwise 8 is a reasonably good balance between detail and the number of labels added. |
outline |
logical whether to enable outline drawing. |
alphaOutline , alphaShadow |
alpha transparency to use for the outline and shadow colors, respectively. |
shadow |
logical whether to enable shadow drawing. |
shadowOrder |
|
doTest |
logical whether to create a visual example of output. Note
that it calls |
... |
other parameters are passed to |
Draws text with the same syntax as graphics::text()
except that
this function adds a contrasting color border around the text, which
helps visibility when the background color is either not known, or is
not expected to be a fixed contrasting color.
The function draws the label n times with the chosed background color, then the label itself atop the background text. It does not typically have a noticeable effect on rendering time, but it may impact downstream uses in vector file formats like SVG and PDF, where text is stored as proper text and font objects. Take care when editing text that the underlying shadow text is also edited in sync.
The parameter doTest=TRUE
will display a visual example. The
background color can be modified with fill="navy"
for example.
invisible list
of components used to call graphics::text()
,
including: x, y, allColors, allLabels, cex, font.
Other jam plot functions:
adjustAxisLabelMargins()
,
coordPresets()
,
decideMfrow()
,
drawLabels()
,
getPlotAspect()
,
groupedAxis()
,
imageByColors()
,
imageDefault()
,
minorLogTicksAxis()
,
nullPlot()
,
plotPolygonDensity()
,
plotRidges()
,
plotSmoothScatter()
,
shadowText_options()
,
showColors()
,
smoothScatterJam()
,
sqrtAxis()
,
usrBox()
shadowText(doTest=TRUE);
shadowText(doTest=TRUE, fill="navy");
shadowText(doTest=TRUE, fill="red4");
# example showing labels with overlapping shadows
opar <- par("mfrow"=c(1, 2))
nullPlot(doBoxes=FALSE);
title(main="shadowOrder='each'");
shadowText(x=c(1.5, 1.65), y=c(1.5, 1.55),
labels=c("one", "two"), cex=c(2, 4), shadowOrder="each")
nullPlot(doBoxes=FALSE);
title(main="shadowOrder='all'");
shadowText(x=c(1.5, 1.65), y=c(1.5, 1.55),
labels=c("one", "two"), cex=c(2, 4), shadowOrder="all")
par(opar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.