xkcdrect: Draw fuzzy rectangles

View source: R/xkcdrect.R

xkcdrectR Documentation

Draw fuzzy rectangles

Description

It draws fuzzy rectangles.

Usage

xkcdrect(
  mapping,
  data,
  ...,
  fillcolour = "grey90",
  bordercolour = "black",
  borderlinewidth = 0.5,
  borderxjitteramount = 0.005,
  borderyjitteramount = 0.005
)

Arguments

mapping

Mapping between variables and aesthetics generated by aes. See Details.

data

Dataset used in this layer.

...

Optional arguments.

fillcolour

The fill colour of the rectangle.

bordercolour

The colour of the fuzzy border lines.

borderlinewidth

The thickness of the fuzzy border lines. This is the package's implementation of the linewidth aesthetic.

borderxjitteramount

Horizontal jitter amount for the border.

borderyjitteramount

Vertical jitter amount for the border.

Details

This function draws fuzzy rectangles.

It plots rectangles. The following aesthetics are required:

  1. xmin

  2. ymin

  3. xmax

  4. ymax

Additionally, you can use the aesthetics of geom_path and geom_rect.

Value

A layer.

See Also

aes, geom_path

Examples

## Not run: 
volunteers <- data.frame(year = c(2007:2011),
                         number = c(56470, 56998, 59686, 61783, 64251))

xrange <- range(volunteers$year)
yrange <- range(volunteers$number)

p <- ggplot() + 
     xkcdrect(aes(xmin = year - 0.2, 
                  xmax = year + 0.2,
                  ymin = number - 500,
                  ymax = number + 500),
              data = volunteers, 
              fillcolour = "pink",
              borderlinewidth = 1.2) +
     geom_point(aes(x = year, y = number), data = volunteers) +
     xkcdaxis(xrange, yrange) +
     theme_xkcd()
p

## End(Not run)

xkcd documentation built on Nov. 20, 2025, 1:07 a.m.