wiggle: Wiggle style

View source: R/style_wiggle.R

wiggleR Documentation

Wiggle style

Description

'Wiggle' is a theme style that adds an amount of cumulative uniform noise to interpolated lines, making them wiggle a bit. The functions are used in the following way:

wiggle()

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

element_rect_wiggle(), element_line_wiggle

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

wiggling_geoms()

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

Usage

wiggle(amount = 3, seed = NULL)

element_line_wiggle(amount = 3, seed = NULL, ...)

element_rect_wiggle(amount = 3, seed = NULL, ...)

wiggling_geoms(
  amount = 5,
  fill = NULL,
  colour = NULL,
  linewidth = NULL,
  linetype = NULL,
  color = NULL,
  lineend = NULL,
  sides = "tlbr",
  seed = NULL,
  n = 50
)

Arguments

amount

A numeric of length 1 setting the amount of wiggling to occur.

seed

An integer to set the seed for reproducible wiggling.

...

Arguments passed to element_*_seq().

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.

n

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

Details

The amount of wiggle added to lines and rectangles is absolute. This makes it easier to make more uniform wiggles, but causes relative distortion when resizing the plot window or device.

Value

For wiggle(), a function.

For element_rect_wiggle(), an element_rect_seq type list.

For element_line_wiggle(), an element_line_seq type list.

For wiggling_geoms, a partial theme object.

See Also

Other theme styles: glow(), multicolour()

Examples

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

# Making geoms wiggle
barplot + wiggling_geoms()

# Making only line geoms wiggle
barplot + theme(elementalist.geom_line = element_line_wiggle(10))

# Making only rect geoms wiggle
barplot + theme(elementalist.geom_rect = element_rect_wiggle(5))

# Let other theme elements wiggle
barplot + theme(
  axis.line.x = element_line_wiggle(),
  axis.line.y = element_line_wiggle(),
  legend.background = element_rect_wiggle(colour = "grey20")
)

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