View source: R/utilities-background.R
addWatermark | R Documentation |
Creates a ggplot
grob based on the label text and its font properties.
Then, adds the grob to the ggplot
object as a new layer using ggplot2::annotation_custom
.
addWatermark(
plotObject,
watermark,
color = NULL,
size = NULL,
angle = NULL,
alpha = NULL
)
plotObject |
A |
watermark |
A character value or a |
color |
Color of the watermark. |
size |
Size of the watermark. |
angle |
Angle of the watermark (in degree). |
alpha |
Numeric value between 0 and 1 corresponding to transparency of the watermark The closer to 0, the more transparent the watermark is. The closer to 1, the more opaque the watermark is. |
A ggplot
object
# Add a watermark to an empty plot
p <- ggplot2::ggplot()
addWatermark(p, "watermark")
# Watermark with font properties
watermarkLabel <- Label$new(text = "watermark", color = "blue")
addWatermark(p, watermarkLabel)
# Horizontal watermark
addWatermark(p, watermarkLabel, angle = 0)
# Watermark totally opaque
addWatermark(p, watermarkLabel, alpha = 1)
# As multiple layers of watermark:
p2 <- addWatermark(p, watermarkLabel, alpha = 1)
addWatermark(p2, "other watermark", color = "red", angle = 90)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.