Skip to contents

Draws filled rectangles with a hand-drawn roughened outline and a hachure, cross-hatch, zigzag, dots, dashed, or solid fill. geom_sketch_rect() takes the xmin/xmax/ymin/ymax aesthetics; geom_sketch_tile() takes x/y centres with optional width/height (like ggplot2::geom_tile()).

Usage

GeomSketchRect

geom_sketch_rect(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  roughness = NULL,
  bowing = 1,
  n_passes = 2L,
  seed = NULL,
  fill_style = "hachure",
  hachure_angle = 45,
  hachure_gap = NULL,
  fill_weight = 0.5,
  corner_radius = 0,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

GeomSketchTile

geom_sketch_tile(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  width = NULL,
  height = NULL,
  roughness = NULL,
  bowing = 1,
  n_passes = 2L,
  seed = NULL,
  fill_style = "hachure",
  hachure_angle = 45,
  hachure_gap = NULL,
  fill_weight = 0.5,
  corner_radius = 0,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping

Set of aesthetic mappings created by ggplot2::aes().

data

Data to display.

stat

Statistical transformation. Default "identity".

position

Position adjustment. Default "identity".

...

Other arguments passed on to the layer.

roughness

Non-negative roughness (0 = straight). A mappable aesthetic (default 1): pass a constant, or map it per rectangle with aes(roughness = ) (rescaled by scale_roughness_continuous()).

bowing

Non-negative bowing multiplier. Default 1.

n_passes

Number of stroke passes. Default 2.

seed

Integer seed. NULL uses getOption("ggsketch.seed", 1L).

fill_style

One of "hachure", "cross_hatch", "zigzag", "zigzag_line", "scribble", "dots", "dashed", "stipple", "pencil_shade", or "solid". Default "hachure".

hachure_angle

Fill line angle in degrees. Default 45.

hachure_gap

Fill line gap in device inches (NULL = 15% of the rectangle's smaller drawn side, clamped to [0.04, 0.4] inches).

fill_weight

Stroke weight for fill lines. Default 0.5.

corner_radius

Corner rounding as a fraction [0, 1] of each half-side. 0 (default) gives sharp corners; 1 fully rounds the ends.

na.rm

Remove missing values silently? Default FALSE.

show.legend

Logical; include in legend?

inherit.aes

Override default aesthetics?

width, height

Tile size overrides for geom_sketch_tile(). NULL uses the data resolution.

Value

A ggplot2 layer object.

Examples

library(ggplot2)
df <- data.frame(xmin = 1, xmax = 3, ymin = 1, ymax = 4)
ggplot(df) +
  geom_sketch_rect(aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax),
                   corner_radius = 0.3, seed = 1L) +
  theme_sketch()