geom_spiro {ggforce} | R Documentation |
Draw spirograms based on the radii of the different "wheels" involved
Description
This, rather pointless, geom allows you to draw spirograms, as known from the popular drawing toy where lines were traced by inserting a pencil into a hole in a small gear that would then trace around inside another gear. The potential practicality of this geom is slim and it excists mainly for fun and art.
Usage
stat_spiro(
mapping = NULL,
data = NULL,
geom = "path",
position = "identity",
na.rm = FALSE,
n = 500,
revolutions = NULL,
show.legend = NA,
inherit.aes = TRUE,
...
)
geom_spiro(
mapping = NULL,
data = NULL,
stat = "spiro",
position = "identity",
arrow = NULL,
n = 500,
lineend = "butt",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data, either as a
|
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
na.rm |
If |
n |
The number of points that should be used to draw a fully closed
spirogram. If |
revolutions |
The number of times the inner gear should revolve around
inside the outer gear. If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Other arguments passed on to |
stat |
The statistical transformation to use on the data for this
layer, either as a |
arrow |
Arrow specification, as created by |
lineend |
Line end style (round, butt, square). |
Aesthetics
stat_spiro and geom_spiro understand the following aesthetics (required aesthetics are in bold):
-
R
-
r
-
d
x0
y0
outer
color
size
linetype
alpha
Computed variables
- x, y
The coordinates for the path describing the spirogram
- index
The progression along the spirogram mapped between 0 and 1
Examples
# Basic usage
ggplot() +
geom_spiro(aes(R = 10, r = 3, d = 5))
# Only draw a portion
ggplot() +
geom_spiro(aes(R = 10, r = 3, d = 5), revolutions = 1.2)
# Let the inner gear circle the outside of the outer gear
ggplot() +
geom_spiro(aes(R = 10, r = 3, d = 5, outer = TRUE))