glow: Glowing lines

View source: R/style_glow.R

glowR Documentation

Glowing lines

Description

Makes copies of lines with increasing linewidth and decreasing alpha, giving an glowing appearance. The functions are used in the following way:

glow()

is a function factory that produces a function that is subsequently used in elements to make lines glow

element_rect_glow(), element_line_glow

are convenience wrappers around element_*_seq() that pass down the function generated by glow().

glowing_geoms()

is a convenience theme setter for the elementalist.geom_rect and elementalist.geom_line elements.

Usage

glow(amount = 3)

element_line_glow(amount = 3, ...)

element_rect_glow(amount = 3, ...)

element_polygon_glow(amount = 3, n = 50, ...)

glowing_geoms(
  amount = 3,
  fill = NULL,
  colour = NULL,
  linewidth = NULL,
  linetype = NULL,
  color = NULL,
  lineend = NULL,
  sides = "tlbr",
  n = 50
)

Arguments

amount

A numeric larger than 0 for the amount of glow to add.

...

Arguments passed to element_*_seq().

n

An integer of length one indicating how many points to interpolate.

fill

Fill colour.

colour, color

Line/border colour. Color is an alias for colour.

linewidth

Line/border size in mm.

linetype

Line type. An integer (0:8), a name (blank, solid, dashed, dotted, dotdash, longdash, twodash), or a string with an even number (up to eight) of hexadecimal digits which give the lengths in consecutive positions in the string.

lineend

Line end Line end style (round, butt, square)

sides

A character of length one containing any of "t", "l", "b" and/or "r". If these letters are present, edges are drawn at the top (t), left (l), bottom (b) or right (r), respectively. Including all these letters will draw all rectangle edges (default), whereas including none of these letters will not draw edges.

Details

When the elements have no colours by setting them to NA, this will not draw glowing lines, as is to be expected.

Due to the way glowing lines are constructed, having non-solid linetypes may lead to awkward results.

Value

For glow(), a function.

For element_rect_glow(), an element_rect_seq type list.

For element_line_glow(), an element_line_seq type list.

For glowing_geoms, a partial theme object.

See Also

Other theme styles: multicolour(), wiggle()

Examples

barplot <- ggplot(mpg, aes(class)) +
  geom_bar_theme(aes(colour = class)) +
  geom_line_theme(stat = "count", aes(group = -1))

# Making geoms glow
barplot + glowing_geoms()

# Making only line geoms glow
barplot + theme(elementalist.geom_line = element_line_glow(colour = "magenta"))

# Making only rect geoms glow
barplot + theme(elementalist.geom_rect = element_rect_glow(fill = "grey50"))

# Let other theme elements glow
barplot + theme(
  axis.line.x = element_line_glow(colour = "magenta"),
  axis.line.y = element_line_glow(colour = "cyan"),
  legend.background = element_rect_glow(colour = "yellow")
)

teunbrand/elementalist documentation built on Oct. 13, 2024, 11:11 a.m.