| Type: | Package |
| Title: | Plotting 'ggplot2' Graphics in an 'XKCD' Style |
| Version: | 0.1.1 |
| Date: | 2026-08-19 |
| VignetteBuilder: | knitr |
| Description: | Provides custom geoms and themes to create charts and graphics in the distinctive, hand-drawn 'XKCD' webcomic style using the 'ggplot2' framework. The package utilizes custom layers for jittered lines, segments, circles, and figures, and includes a theme that supports the necessary 'XKCD' font. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/ToledoEM/xkcd, https://toledoem.github.io/xkcd/ |
| BugReports: | https://github.com/ToledoEM/xkcd/issues |
| Depends: | R (≥ 4.0), ggplot2 (≥ 3.4.0) |
| Imports: | Hmisc, stats, grid, extrafont |
| Suggests: | knitr, rmarkdown, zoo, reshape, splancs, pkgdown, palmerpenguins, dplyr, ggrepel, systemfonts, covr, testthat (≥ 3.0.0) |
| Encoding: | UTF-8 |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-08-19 18:43:13 UTC; enrique |
| Author: | Emilio Torres-Manzanera [aut], Enrique Toledo [ctb, cre] |
| Maintainer: | Enrique Toledo <enriquetoledo@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-08-20 00:30:02 UTC |
Plotting 'ggplot2' Graphics in an 'XKCD' Style
Description
Provides custom geoms and themes to create charts and graphics in the distinctive, hand-drawn 'XKCD' webcomic style using the 'ggplot2' framework. The package utilizes custom layers for jittered lines, segments, circles, and figures, and includes a theme that supports the necessary 'XKCD' font.
Details
The DESCRIPTION file:
| Package: | xkcd |
| Type: | Package |
| Title: | Plotting 'ggplot2' Graphics in an 'XKCD' Style |
| Version: | 0.1.1 |
| Date: | 2026-08-19 |
| Authors@R: | c( person(given = "Emilio", family = "Torres-Manzanera", role = "aut", email= "torres@uniovi.es"), person(given = "Enrique", family = "Toledo", role = c("ctb", "cre"), email = "enriquetoledo@gmail.com")) |
| VignetteBuilder: | knitr |
| Description: | Provides custom geoms and themes to create charts and graphics in the distinctive, hand-drawn 'XKCD' webcomic style using the 'ggplot2' framework. The package utilizes custom layers for jittered lines, segments, circles, and figures, and includes a theme that supports the necessary 'XKCD' font. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/ToledoEM/xkcd, https://toledoem.github.io/xkcd/ |
| BugReports: | https://github.com/ToledoEM/xkcd/issues |
| Depends: | R (>= 4.0), ggplot2 (>= 3.4.0) |
| Imports: | Hmisc, stats, grid, extrafont |
| Suggests: | knitr, rmarkdown, zoo, reshape, splancs, pkgdown, palmerpenguins, dplyr, ggrepel, systemfonts, covr, testthat (>= 3.0.0) |
| Encoding: | UTF-8 |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.0 |
| Author: | Emilio Torres-Manzanera [aut], Enrique Toledo [ctb, cre] |
| Maintainer: | Enrique Toledo <enriquetoledo@gmail.com> |
Index of help topics:
GeomXkcdRect GeomXkcdRect: fuzzy rectangle geom (XKCD style)
geom_xkcdpath GeomXkcdPath: fuzzy path/circle geom (XKCD
style)
theme_xkcd Creates an XKCD theme
xkcd-package Plotting 'ggplot2' Graphics in an 'XKCD' Style
xkcdaxis Plot the axis
xkcdman Draw a stick figure
xkcdrect Draw fuzzy rectangles
Author(s)
Emilio Torres-Manzanera [aut], Enrique Toledo [ctb, cre]
Maintainer: Enrique Toledo <enriquetoledo@gmail.com>
Examples
## Not run: vignette("xkcd-intro")
GeomXkcdRect: fuzzy rectangle geom (XKCD style)
Description
Draws each rectangle as a standard filled rect with four jittered, Bezier-smoothed border segments on top.
GeomXkcdPath: fuzzy path/circle geom (XKCD style)
Description
A ggplot2 geom that draws jittered, smoothed paths or fuzzy circles. It expects aesthetics like 'x', 'y', and either 'xend'/'yend' (for segments) or 'diameter' (for circles). Additional aesthetics (colour, alpha, linewidth, linetype) are respected.
Usage
geom_xkcdpath(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
xjitteramount = 0.01,
yjitteramount = 0.01,
wobble = 1,
seed = NULL,
mask = TRUE,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
mapping |
Aesthetic mapping. |
data |
Data frame. |
stat |
The statistical transformation to use on the data for this layer. |
position |
Position adjustment. |
... |
Other arguments passed on to layer(). |
xjitteramount |
Horizontal jitter amount for segments, in data units. |
yjitteramount |
Vertical jitter amount for segments, in data units. |
wobble |
Scalar multiplier applied to both jitter amounts. '1' leaves the jitter amounts unchanged; '0' draws straight lines. |
seed |
Optional integer. When supplied the wobble is reproducible: the same 'seed' always yields the same path. Each row of 'data' is offset from 'seed' so rows still differ from one another. The global RNG state is left untouched. |
mask |
Logical; if TRUE draws a thicker white mask path under the main path. |
show.legend |
Show legend. |
inherit.aes |
Whether to inherit aesthetics from the plot. |
Creates an XKCD theme
Description
This function creates an XKCD theme, applying the 'xkcd' font if available.
Usage
theme_xkcd()
Value
A theme object.
Note
The "xkcd" font must be installed on your system for the full effect. Modern
graphics devices pick it up directly; registering it with extrafont is
only needed for pdf/postscript output. See the vignette
vignette("xkcd-intro") for installation instructions.
Examples
## Not run:
# Assuming 'xkcd' font is installed and registered:
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
theme_xkcd()
p
## End(Not run)
Plot the axis
Description
This function plots the axis in an XKCD style.
Usage
xkcdaxis(xrange, yrange, ...)
Arguments
xrange |
The range of the X axe. |
yrange |
The range of the Y axe. |
... |
Other arguments passed to geom_xkcdpath. |
Value
A list of layers containing the axes, coordinate system, and theme.
Examples
## Not run:
xrange <- range(mtcars$mpg)
yrange <- range(mtcars$wt)
p <- ggplot() +
geom_point(aes(mpg, wt), data=mtcars) +
xkcdaxis(xrange,yrange)
p
## End(Not run)
Draw lines or circles
Description
Deprecated in favour of [geom_xkcdpath()], which integrates with ggplot2's aesthetic machinery instead of rebuilding mappings by hand. Migrate segments to 'geom_xkcdpath(aes(x = x, y = y, xend = xend, yend = yend), ...)' and circles to the 'diameter' aesthetic.
Usage
xkcdline(mapping, data, typexkcdline = "segment", mask = TRUE, ...)
Arguments
mapping |
Aesthetic mapping |
data |
Dataset |
typexkcdline |
"segment" or "circunference" |
mask |
Logical |
... |
Additional arguments |
See Also
[geom_xkcdpath()]
Draw a stick figure
Description
Draws one stick figure per row of 'data'. The figure is built from eight fuzzy elements – a circular head plus seven bones (spine, two humeri, two radii and two legs) – which are emitted as just two [geom_xkcdpath()] layers.
Usage
xkcdman(mapping, data, seed = NULL, ...)
Arguments
mapping |
Aesthetic mapping |
data |
Dataset |
seed |
Optional integer for a reproducible figure. See [geom_xkcdpath()]. |
... |
Optional arguments passed on to [geom_xkcdpath()]. |
Details
The following aesthetics are required, supplied through 'mapping' or as columns of 'data': 'x' and 'y' (centre of the head), 'scale' (overall size), 'ratioxy' (the x/y scale ratio, which keeps the figure from being distorted when the axes have different units), and the angles 'angleofspine', 'anglerighthumerus', 'anglelefthumerus', 'anglerightradius', 'angleleftradius', 'anglerightleg', 'angleleftleg' and 'angleofneck'.
See Also
[geom_xkcdpath()]
Draw fuzzy rectangles
Description
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 |
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 |
borderxjitteramount |
Horizontal jitter amount for the border. |
borderyjitteramount |
Vertical jitter amount for the border. |
wobble |
Scalar multiplier applied to both jitter amounts. |
seed |
Optional integer for a reproducible border. See |
na.rm |
If |
show.legend |
Show legend. |
inherit.aes |
Whether to inherit aesthetics from the plot. |
fillcolour |
Deprecated. Use the |
bordercolour |
Deprecated. Use the |
borderlinewidth |
Deprecated. Use the |
Details
This function draws rectangles with hand-drawn, wobbly borders.
The following aesthetics are required:
xmin
ymin
xmax
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.
Value
A layer.
See Also
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,
fill = "pink",
linewidth = 1.2) +
geom_point(aes(x = year, y = number), data = volunteers) +
xkcdaxis(xrange, yrange) +
theme_xkcd()
p
## End(Not run)