Learn R Programming

ggsketch (version 2.0.0)

element_sketch_line: Hand-drawn theme elements

Description

Sketch counterparts of ggplot2::element_line() and ggplot2::element_rect(). Use them in ggplot2::theme() (or via theme_sketch(rough_frame = TRUE)) to render gridlines, panel borders, and axis ticks with the same wobbly, double-stroke look as the geoms. They accept the usual element arguments plus the shared sketch parameters (roughness, bowing, n_passes, seed).

Usage

element_sketch_line(
  colour = NULL,
  linewidth = NULL,
  linetype = NULL,
  lineend = NULL,
  color = NULL,
  roughness = 0.5,
  bowing = 0.5,
  n_passes = 2L,
  seed = NULL,
  ...
)

element_sketch_rect( fill = NULL, colour = NULL, linewidth = NULL, linetype = NULL, color = NULL, roughness = 0.6, bowing = 0.4, n_passes = 2L, seed = NULL, ... )

Value

A ggplot2 theme element carrying an element_sketch_* subclass.

Arguments

colour, color

Line/border colour.

linewidth

Line width.

linetype

Line type.

lineend

Line end style.

roughness, bowing, n_passes, seed

Sketch parameters (see geom_sketch_path()). Defaults are gentle, suited to a frame.

...

Passed to the underlying ggplot2 element constructor.

fill

Fill colour (element_sketch_rect() only). NA draws the outline only - the usual choice for a panel border.

See Also

Other sketch-theme: CoordSketch, CoordSketchPolar, ggsketch_check_fonts(), ggsketch_save(), register_sketch_font(), scale_pressure_continuous(), scale_roughness_continuous(), scale_sketch, scale_tone_continuous(), sketch_palette(), theme_sketch()

Examples

Run this code
library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
  geom_sketch_point(seed = 1L) +
  theme_sketch() +
  theme(panel.grid.major = element_sketch_line(colour = "grey80", seed = 7L))

Run the code above in your browser using DataLab