| Type: | Package |
| Title: | Plotting 'ggplot2' Graphics in an 'XKCD' Style |
| Version: | 0.1.0 |
| Date: | 2025-10-23 |
| Maintainer: | Enrique Toledo <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 |
| 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 |
| NeedsCompilation: | no |
| Packaged: | 2025-11-19 17:20:38 UTC; enrique |
| Author: | Emilio Torres-Manzanera [aut], Enrique Toledo [ctb, cre] |
| Repository: | CRAN |
| Date/Publication: | 2025-11-19 17:50:01 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.0 |
| Date: | 2025-10-23 |
| Maintainer: | Enrique Toledo <enriquetoledo@gmail.com> |
| 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 |
| 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 |
| 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
Author(s)
Emilio Torres-Manzanera [aut], Enrique Toledo [ctb, cre]
Maintainer: Enrique Toledo <enriquetoledo@gmail.com>
Examples
## Not run: vignette("xkcd-intro")
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,
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. |
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. |
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 and registered with extrafont for the
full effect. 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
Draw lines or circles
Usage
xkcdline(mapping, data, typexkcdline = "segment", mask = TRUE, ...)
Arguments
mapping |
Aesthetic mapping |
data |
Dataset |
typexkcdline |
"segment" or "circunference" |
mask |
Logical |
... |
Additional arguments |
Draw a stick figure
Description
Draw a stick figure
Usage
xkcdman(mapping, data, ...)
Arguments
mapping |
Aesthetic mapping |
data |
Dataset |
... |
Optional arguments |
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 |
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. |
Details
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.
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,
fillcolour = "pink",
borderlinewidth = 1.2) +
geom_point(aes(x = year, y = number), data = volunteers) +
xkcdaxis(xrange, yrange) +
theme_xkcd()
p
## End(Not run)