Type: | Package |
Title: | Plotting ggplot2 Graphics in an XKCD Style |
Version: | 0.0.6 |
Date: | 2018-07-10 |
Author: | Emilio Torres-Manzanera |
Maintainer: | Emilio Torres-Manzanera <torres@uniovi.es> |
Description: | Plotting ggplot2 graphs using the XKCD style. |
License: | GPL-3 |
Depends: | ggplot2 (≥ 3.0), extrafont |
Imports: | Hmisc, stats |
NeedsCompilation: | no |
Packaged: | 2018-07-11 14:49:14 UTC; emilio |
RoxygenNote: | 6.0.1 |
Repository: | CRAN |
Date/Publication: | 2018-07-11 15:30:02 UTC |
Plotting ggplot2 Graphics in an XKCD Style
Description
Plotting ggplot2 graphs using the XKCD style.
Details
The DESCRIPTION file:
Package: | xkcd |
Type: | Package |
Title: | Plotting ggplot2 Graphics in an XKCD Style |
Version: | 0.0.6 |
Date: | 2018-07-10 |
Author: | Emilio Torres-Manzanera |
Maintainer: | Emilio Torres-Manzanera <torres@uniovi.es> |
Description: | Plotting ggplot2 graphs using the XKCD style. |
License: | GPL-3 |
Depends: | ggplot2 (>= 3.0), extrafont |
Imports: | Hmisc, stats |
URL: | |
NeedsCompilation: | no |
Packaged: | 2016-01-13 10:16:52 UTC; emilio |
RoxygenNote: | 6.0.1 |
Index of help topics:
theme_xkcd Creates an XKCD theme xkcd-package Plotting ggplot2 Graphics in an XKCD Style xkcdaxis Plot the axis xkcdline Draw lines or circunferences xkcdman Draw a stick figure xkcdrect Draw fuzzy rectangles
Further information is available in the following vignettes:
xkcd-intro | Using xkcd (source, pdf) |
Author(s)
Emilio Torres-Manzanera
Maintainer: Emilio Torres-Manzanera <torres@uniovi.es>
Examples
## Not run: vignette("xkcd-intro")
Creates an XKCD theme
Description
This function creates an XKCD theme
Usage
theme_xkcd()
Value
A layer with the theme.
Note
See the vignette vignette("xkcd-intro")
Examples
## Not run:
p <- ggplot() + geom_point(aes(mpg, wt), data=mtcars) +
theme_xkcd()
p
## End(Not run)
Plot the axis
Description
This function plots the axis
Usage
xkcdaxis(xrange, yrange, ...)
Arguments
xrange |
The range of the X axe. |
yrange |
The range of the Y axe. |
... |
Other arguments. |
Details
It plots the axis of the graph.
Value
A layer with the axis.
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 circunferences
Description
It draws a handwritten line.
Usage
xkcdline(mapping, data, typexkcdline = "segment", mask = TRUE, ...)
Arguments
mapping |
Mapping between variables and aesthetics generated by |
data |
Dataset used in this layer. |
typexkcdline |
A string value. If it is |
mask |
Logical. If it is TRUE, it erases the pictures that are under the line. |
... |
Optional arguments. |
Details
This function draws handwritten lines or circles.
It draws a segment or a circunference in an XKCD style.
If it is a segment, the following aesthetics are required:
xbegin: x position of the point from.
ybegin: y position of the point from.
xend: x position of the point to.
yend: y position of the point to.
If it is a circunference, the following aesthetics are required:
x: x position of the center.
y: y position of the center.
diameter: diameter of the circunference.
Additionally, you can use the aesthetics of geom_path
.
Value
A layer.
See Also
Examples
data <- data.frame(x1=c(1,2), y1=c(10,20), xend=c(2.5,0.5),
yend=c(20,10), model=c("low","high"))
ggplot() + xkcdline(mapping=aes(x=x1 +y1, y=y1, xend =xend, yend= yend,
color = model), data=data)
ggplot() + xkcdline(mapping=aes(x=x1 +y1, y=y1, xend =xend, yend= yend,
color = model), data=data) + facet_grid(. ~ model)
ggplot() + xkcdline(mapping=aes(x=x1 +y1, y=y1, diameter =xend), data=data, type="circunference")
Draw a stick figure
Description
It draws a stick figure
Usage
xkcdman(mapping, data, ...)
Arguments
mapping |
Mapping between variables and aesthetics generated by |
data |
Dataset used in this layer. |
... |
Optional arguments. |
Details
This function draws a stick figure.
The following aesthetics are required:
x: x position of the center of the head.
y: y position of the center of the head.
scale: scale of the man. It is the size of the man (in units of the Y axis).
ratioxy: Ratio x to y of the graph (Use ratioxy <- diff(xrange) / diff(yrange))
angleofspine: angle between the spine and a horizontal line that passes by the center of the head.
anglerighthumerus, anglelefthumerus: angle between the right/left humerus and a horizontal line that passes by the top of the spine.
anglerightradius, angleleftradius: angle between the right/left radius and a horizontal line that passes by the end of the right/left humerus.
anglerightleg, anglelefthleg: angle between the right/left left and a horizontal line that passes by the end of the end of the spine.
angleofneck: angle between the begin of spine and a horizontal line that passes by the center of the head.
Angles are in radians.
Additionally, you can use the aesthetics of geom_path
,
and xkcdline
.
Value
A layer.
See Also
Examples
datascaled <- data.frame(x=c(-3,3),y=c(-30,30))
p <- ggplot(data=datascaled, aes(x=x,y=y)) + geom_point()
xrange <- range(datascaled$x)
yrange <- range(datascaled$y)
ratioxy <- diff(xrange) / diff(yrange)
mapping <- aes(x=x,
y=y,
scale=scale,
ratioxy=ratioxy,
angleofspine = angleofspine,
anglerighthumerus = anglerighthumerus,
anglelefthumerus = anglelefthumerus,
anglerightradius = anglerightradius,
angleleftradius = angleleftradius,
anglerightleg = anglerightleg,
angleleftleg = angleleftleg,
angleofneck = angleofneck,
color = color )
dataman <- data.frame( x= c(-1,0,1), y=c(-10,0,10),
scale = c(10,7,5),
ratioxy = ratioxy,
angleofspine = seq(- pi / 2, -pi/2 + pi/8, l=3) ,
anglerighthumerus = -pi/6,
anglelefthumerus = pi + pi/6,
anglerightradius = 0,
angleleftradius = runif(3,- pi/4, pi/4),
angleleftleg = 3*pi/2 + pi / 12 ,
anglerightleg = 3*pi/2 - pi / 12,
angleofneck = runif(3, min = 3 * pi / 2 - pi/10 , max = 3 * pi / 2 + pi/10),
color=c("A","B","C"))
p + xkcdman(mapping,dataman)
Draw fuzzy rectangles
Description
It draws fuzzy rectangles.
Usage
xkcdrect(mapping, data, ...)
Arguments
mapping |
Mapping between variables and aesthetics generated by |
data |
Dataset used in this layer. |
... |
Optional arguments. |
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
volunteers <- data.frame(year=c(2007:2011),
number=c(56470, 56998,59686, 61783, 64251))
p <- ggplot() + xkcdrect(aes(xmin = year,
xmax= year +0.3,
ymin=number,
ymax = number + 3600),
volunteers,
fill="red", colour="black")
p