polygon_glow | R Documentation |
Forms a grob graphical object that will draw polygons with a glow.
polygon_glow(
x,
y,
id,
sub_id = id,
gp = gpar(),
n = 10,
amount = 3,
bg = TRUE,
closed = FALSE,
rule = "evenodd",
...
)
x , y |
A |
id , sub_id |
A |
n |
An |
amount |
A |
bg |
A |
closed |
A |
... |
Other arguments passed on to the |
colour , fill |
A colour specification of either length 1 or of the same
length as |
lwd |
A |
lty |
A linetype specification of either length 1 or of the same length
as |
The glowing effect is achieved by copying the polygon several times with increasing width and decreasing alpha.
Will make separate foreground (lines) and background (fills) grobs.
A list
with elements fg
and bg
which are grobs
or NULL
.
# Some example data
df <- data.frame(
x = c(0, 0.5, 1, 0.5, 0.25, 0.5, 0.75, 0.5),
y = c(0.5, 0, 0.5, 1, 0.5, 0.25, 0.5, 0.75),
sub_id = rep(c(1, 2), each = 4),
id = rep(1, each = 8)
)
# Constructing polygon
pgon <- polygon_glow(
df$x, df$y,
df$id, df$sub_id,
colour = c("blue", "red"), lty = c(1, 4),
fill = "grey50", n = 50, closed = TRUE, lwd = 3
)
# Rendering in grid
grid.newpage()
grid.draw(pgon$bg)
grid.draw(pgon$fg)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.