Skip to contents

It draws fuzzy rectangles.

Usage

xkcdrect(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  borderxjitteramount = 0.005,
  borderyjitteramount = 0.005,
  wobble = 1,
  seed = NULL,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  fillcolour,
  bordercolour,
  borderlinewidth
)

Arguments

mapping

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

data

Dataset used in this layer.

stat

The statistical transformation to use on the data for this layer.

position

Position adjustment.

...

Other arguments passed on to layer.

borderxjitteramount

Horizontal jitter amount for the border.

borderyjitteramount

Vertical jitter amount for the border.

wobble

Scalar multiplier applied to both jitter amounts. 1 leaves them unchanged; 0 draws straight borders.

seed

Optional integer for a reproducible border. See geom_xkcdpath.

na.rm

If FALSE, missing values are removed with a warning.

show.legend

Show legend.

inherit.aes

Whether to inherit aesthetics from the plot.

fillcolour

Deprecated. Use the fill aesthetic.

bordercolour

Deprecated. Use the colour aesthetic.

borderlinewidth

Deprecated. Use the linewidth aesthetic.

Value

A layer.

Details

This function draws rectangles with hand-drawn, wobbly borders.

The following aesthetics are required:

  1. xmin

  2. ymin

  3. xmax

  4. ymax

The fill and border are controlled with the standard fill, colour and linewidth aesthetics, so they may be mapped to variables in the usual way.

See also

Examples

if (FALSE) { # \dontrun{
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,
              fill = "pink",
              linewidth = 1.2) +
     geom_point(aes(x = year, y = number), data = volunteers) +
     xkcdaxis(xrange, yrange) +
     theme_xkcd()
p
} # }