| Title: | 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. |
| Authors: | Emilio Torres-Manzanera [aut], Enrique Toledo [ctb, cre] |
| Maintainer: | Enrique Toledo <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-12 17:43:43 UTC |
| Source: | https://github.com/toledoem/xkcd |
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.
The DESCRIPTION file:
| Package: | xkcd |
| Type: | Package |
| Title: | Plotting 'ggplot2' Graphics in an 'XKCD' Style |
| Version: | 0.1.0 |
| Date: | 2025-10-23 |
| Maintainer: | Enrique Toledo <[email protected]> |
| Authors@R: | c( person(given = "Emilio", family = "Torres-Manzanera", role = "aut", email= "[email protected]"), person(given = "Enrique", family = "Toledo", role = c("ctb", "cre"), email = "[email protected]")) |
| 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, rlang, extrafont |
| Suggests: | knitr, rmarkdown, zoo, reshape, splancs, lattice, pkgdown |
| RoxygenNote: | 7.3.3 |
| Encoding: | UTF-8 |
| Config/pak/sysreqs: | cmake make libicu-dev libuv1-dev |
| Repository: | https://toledoem.r-universe.dev |
| Date/Publication: | 2026-05-12 16:10:27 UTC |
| RemoteUrl: | https://github.com/toledoem/xkcd |
| RemoteRef: | HEAD |
| RemoteSha: | 2cc51c0169baca50a7fe812d2899177d5e6b4925 |
| Author: | Emilio Torres-Manzanera [aut], Enrique Toledo [ctb, cre] |
Index of help topics:
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
xkcdline Draw lines or circles
xkcdman Draw a stick figure
xkcdrect Draw fuzzy rectangles
Emilio Torres-Manzanera [aut], Enrique Toledo [ctb, cre]
Maintainer: Enrique Toledo <[email protected]>
## Not run: vignette("xkcd-intro")## Not run: vignette("xkcd-intro")
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.
geom_xkcdpath( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., xjitteramount = 0.01, yjitteramount = 0.01, mask = TRUE, show.legend = NA, inherit.aes = TRUE )geom_xkcdpath( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., xjitteramount = 0.01, yjitteramount = 0.01, mask = TRUE, show.legend = NA, inherit.aes = TRUE )
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. |
yjitteramount |
Vertical jitter amount for segments. |
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. |
This function creates an XKCD theme, applying the 'xkcd' font if available.
theme_xkcd()theme_xkcd()
A theme object.
The "xkcd" font must be installed and registered with extrafont for the
full effect. See the vignette vignette("xkcd-intro") for installation instructions.
## Not run: # Assuming 'xkcd' font is installed and registered: p <- ggplot(mtcars, aes(mpg, wt)) + geom_point() + theme_xkcd() p ## End(Not run)## Not run: # Assuming 'xkcd' font is installed and registered: p <- ggplot(mtcars, aes(mpg, wt)) + geom_point() + theme_xkcd() p ## End(Not run)
This function plots the axis in an XKCD style.
xkcdaxis(xrange, yrange, ...)xkcdaxis(xrange, yrange, ...)
xrange |
The range of the X axe. |
yrange |
The range of the Y axe. |
... |
Other arguments passed to geom_xkcdpath. |
A list of layers containing the axes, coordinate system, and theme.
## 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)## 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
xkcdline(mapping, data, typexkcdline = "segment", mask = TRUE, ...)xkcdline(mapping, data, typexkcdline = "segment", mask = TRUE, ...)
mapping |
Aesthetic mapping |
data |
Dataset |
typexkcdline |
"segment" or "circunference" |
mask |
Logical |
... |
Additional arguments |
Draw a stick figure
xkcdman(mapping, data, ...)xkcdman(mapping, data, ...)
mapping |
Aesthetic mapping |
data |
Dataset |
... |
Optional arguments |
It draws fuzzy rectangles.
xkcdrect( mapping, data, ..., fillcolour = "grey90", bordercolour = "black", borderlinewidth = 0.5, borderxjitteramount = 0.005, borderyjitteramount = 0.005 )xkcdrect( mapping, data, ..., fillcolour = "grey90", bordercolour = "black", borderlinewidth = 0.5, borderxjitteramount = 0.005, borderyjitteramount = 0.005 )
mapping |
Mapping between variables and aesthetics generated by |
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 |
borderxjitteramount |
Horizontal jitter amount for the border. |
borderyjitteramount |
Vertical jitter amount for the border. |
This function draws fuzzy rectangles.
It plots rectangles. The following aesthetics are required:
xmin
ymin
xmax
ymax
Additionally, you can use the aesthetics of geom_path and geom_rect.
A layer.
## 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)## 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)