Description Usage Arguments Value Examples
The svg_group()
function allows for grouping of several SVG elements. This
is useful if we'd like to pass presentation attributes to several elements
at once.
1 2 3 4 5 6 7 8 9 |
svg |
The |
... |
a collection of named arguments that consist of presentation
attributes (e.g., |
.list |
Allows for the use of a list as an input alternative to |
attrs |
A presentation attribute list. The helper function
|
anims |
An animation directive list for the element. This should be
structured using the |
filters |
A filter directive list for the element. This is easily
created by using a list of |
id |
An optional ID value to give to the built tag. This is useful for modifying this element in a later function call or for interacting with CSS. |
An svg
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | if (interactive()) {
# Create an SVG with two rectangles
# contained within a group
SVG(width = 300, height = 300) %>%
svg_group(
fill = "steelblue", stroke = "red", opacity = 0.5,
~ svg_rect(., x = 20, y = 20, width = 50, height = 50),
~ svg_rect(., x = 40, y = 40, width = 50, height = 50, fill = "red")
)
# Create an SVG with two rectangles
# that are nested within two
# different groups
SVG(width = 300, height = 300) %>%
svg_group(
fill = "green", stroke = "red",
~ svg_rect(., x = 30, y = 30, width = 40, height = 50),
~ svg_group(.,
fill = "steelblue", opacity = 0.5,
~ svg_rect(., x = 60, y = 60, width = 50, height = 50)
)
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.