| registered_patterns | R Documentation |
registered_patterns() returns a data frame of all available patterns.
has_pattern() returns whether pattern names currently resolve to a pattern
i.e. whether grid.pattern() / patternGrob() could use them.
See register_pattern() for how bare pattern names are resolved.
registered_patterns()
has_pattern(pattern)
pattern |
A character vector of bare pattern names |
registered_patterns() returns a data frame with columns
The pattern name.
The package that registered the pattern or "R_GlobalEnv" for the user.
Either "geometry" or "array".
One of "builtin", "register_pattern", or "options".
Whether the bare name currently resolves to this pattern.
has_pattern() returns a logical vector the same length as pattern.
A bare name with an unresolved conflict (see conflicting_patterns()) returns FALSE.
register_pattern() to register patterns.
head(registered_patterns())
has_pattern(c("stripe", "gridpattern::stripe", "polygon"))
create_pattern_polygon <- function(params, boundary_df, aspect_ratio, legend = FALSE) {
grid::polygonGrob(boundary_df$x, boundary_df$y, boundary_df$id,
gp = grid::gpar(fill = params$pattern_fill))
}
# don't clobber any pre-existing "polygon" pattern
run_example <- !has_pattern("polygon")
if (run_example) {
register_pattern("polygon", create_pattern_polygon)
print(subset(registered_patterns(), name == "polygon"))
}
if (run_example) {
print(has_pattern("polygon"))
}
if (run_example) {
unregister_pattern("polygon")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.